-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
40 lines (29 loc) · 805 Bytes
/
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.19.3-alpine3.16
ENV \
CGO_ENABLED=0 \
GOOS=linux
RUN apk add postgresql-client
RUN addgroup -g 1000 -S appgroup && \
adduser -u 1000 -S appuser -G appgroup
WORKDIR /app
COPY go.mod /app
COPY go.sum /app
COPY main.go /app
COPY .env_db /app
COPY .env_app /app
ADD sql /app/sql
ADD static /app/static
ADD templates /app/templates
RUN chown -R appuser:appgroup /app
RUN chown -R appuser:appgroup /go/bin
USER 1000
RUN go mod download
RUN echo ${PGPASSFILE} > /home/appuser/.pgpass && \
chown appuser:appgroup /home/appuser/.pgpass && \
chmod 0600 /home/appuser/.pgpass
# Build the Go app
RUN go build -ldflags "-s -w" -o /go/bin/cycling_blog -buildvcs=false
# Expose port 8080 to the outside world
EXPOSE 8080
# Command to run the executable
CMD ["cycling_blog"]