-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
52 lines (39 loc) · 1.37 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
FROM golang:latest AS build
# Создаем рабочую директорию и компилим
ADD . /app
WORKDIR /app
RUN go build ./cmd/main/main.go
FROM ubuntu:20.04
COPY . .
# Настройка даты
RUN apt-get -y update && apt-get install -y tzdata
ENV TZ=Russia/Moscow
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
# Установка базы
ENV PGVER 12
RUN apt-get -y update && apt-get install -y postgresql-$PGVER
USER postgres
# Настройка базы
RUN /etc/init.d/postgresql start &&\
psql --command "CREATE USER andeo WITH SUPERUSER PASSWORD 'andeo';" &&\
createdb -O andeo andeo &&\
psql -f ./scripts/init.sql -d andeo &&\
/etc/init.d/postgresql stop
RUN echo "host all all 0.0.0.0/0 md5" >> /etc/postgresql/$PGVER/main/pg_hba.conf
RUN echo "listen_addresses='*'" >> /etc/postgresql/$PGVER/main/postgresql.conf
# Настройка конейтейра
VOLUME ["/etc/postgresql", "/var/log/postgresql", "/var/lib/postgresql", "./logs"]
WORKDIR /usr/src/app
COPY . .
COPY --from=build /app/main .
EXPOSE 5000
ENV POSTGRES_USER andeo
ENV POSTGRES_DB andeo
ENV POSTGRES_PASSWORD andeo
ENV POSTGRES_HOST localhost
ENV POSTGRES_PORT 5432
ENV POSTGRES_SSLMODE disable
USER root
RUN mkdir -p ./logs/
RUN chmod -R 777 ./logs/
CMD service postgresql start && ./main -config-path=./cmd/main/configs/prod.toml