-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathDockerfile
62 lines (50 loc) · 1.4 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
53
54
55
56
57
58
59
60
61
# production dockerfile
#------------------------------
# First step: frontend build
#------------------------------
FROM node:20.11.1 AS frontend-builder
WORKDIR /app/webapp
COPY webapp/package*.json ./
RUN npm ci
COPY webapp/ ./
RUN npm run build
#------------------------------
# Second step: golang build
#------------------------------
FROM golang:1.23.3 AS backend-builder
WORKDIR /app/backend
COPY backend/go.mod backend/go.sum ./
RUN go mod download
COPY backend/ ./
RUN go build \
-o morsechat \
-tags 'osusergo,netgo,static,' \
-ldflags '-extldflags "-static"' \
cmd/morsechat/main.go
#------------------------------
# Third step: production image
#------------------------------
FROM nginx:stable-alpine3.20
RUN apk add --update \
supervisor \
sqlite \
&& rm -rf /tmp/* /var/cache/apk/*
#supervisord config
COPY docker/conf/supervisord.conf /etc/
#nginx config
RUN rm /etc/nginx/conf.d/*
COPY docker/conf/nginx.conf /etc/nginx/
COPY docker/conf/webapp.conf /etc/nginx/conf.d/
RUN chown -R nginx /etc/nginx
USER nginx
#nginx webapp
WORKDIR /app/webapp
COPY --chown=nginx --from=frontend-builder /app/webapp/dist ./dist/
#backend
WORKDIR /app/backend
COPY --chown=nginx --from=backend-builder /app/backend/morsechat .
#database
RUN mkdir /app/backend/db/
ENV APP_ENV=production
USER root
ENTRYPOINT ["supervisord", "--nodaemon", "--configuration", "/etc/supervisord.conf"]