-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
executable file
·40 lines (25 loc) · 1.19 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
FROM golang:1.13 AS build
ADD . /app
WORKDIR /app
RUN go build ./app/cmd/main.go
FROM ubuntu:20.04
RUN apt-get -y update && apt-get install -y tzdata
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 artem WITH SUPERUSER PASSWORD '1111';" &&\
createdb -E UTF8 -O artem forums &&\
/etc/init.d/postgresql stop
RUN echo "synchronous_commit = off\nfsync = off\nshared_buffers = 256MB\n" >> /etc/postgresql/$PGVER/main/postgresql.conf
RUN echo "wal_buffers = 2MB\nwal_writer_delay = 50ms\nrandom_page_cost = 1.0\nmax_connections = 100\nwork_mem = 10MB\nmaintenance_work_mem = 128MB\ncpu_tuple_cost = 0.0030\ncpu_index_tuple_cost = 0.0010\ncpu_operator_cost = 0.0005" >> /etc/postgresql/$PGVER/main/postgresql.conf
RUN echo "full_page_writes = off" >> /etc/postgresql/$PGVER/main/postgresql.conf
EXPOSE 5432
VOLUME ["/etc/postgresql", "/var/log/postgresql", "/var/lib/postgresql"]
USER root
WORKDIR /usr/src/app
COPY . .
COPY --from=build /app/main .
EXPOSE 5000
ENV PGPASSWORD 1111
CMD service postgresql start && psql -h localhost -d forums -U artem -p 5432 -a -q -f ./tabels.sql && ./main