-
Notifications
You must be signed in to change notification settings - Fork 20
/
Dockerfile
73 lines (59 loc) · 1.78 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
62
63
64
65
66
67
68
69
70
71
72
73
### API Base ###
#---------------
FROM golang:1.22-alpine AS api-base
WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download
### API Development ###
#----------------------
FROM api-base AS api-dev-env
# - Air provides hot reload for Go
RUN go install github.com/air-verse/air@v1.52.3
# - Copy the files and run a build to make startup faster
COPY api /app/api
WORKDIR /app/api
# - Run a build to make the intial air build faster
RUN CGO_ENABLED=0 go build -ldflags "-s -w" -o /helix
# - Entrypoint is the air command
ENTRYPOINT ["air", "--build.bin", "/helix", "--build.cmd", "CGO_ENABLED=0 go build -ldflags \"-s -w\" -o /helix", "--"]
CMD ["serve"]
#### API Build ###
#-----------------------
FROM api-base AS api-build-env
# Following git lines required for buildvcs to work
RUN apk add --no-cache git
COPY .git /app/.git
COPY api /app/api
WORKDIR /app/api
# - main.version is a variable required by Sentry and is set in .drone.yaml
ARG APP_VERSION="v0.0.0+unknown"
RUN CGO_ENABLED=0 go build -buildvcs=true -ldflags "-s -w -X main.version=$APP_VERSION" -o /helix
### Frontend Base ###
#--------------------
FROM node:21-alpine AS ui-base
WORKDIR /app
# - Install dependencies
COPY ./frontend/*.json /app/
COPY ./frontend/yarn.lock /app/yarn.lock
RUN yarn install
### Frontend Development ###
#---------------------------
FROM ui-base AS ui-dev-env
ENTRYPOINT ["yarn"]
CMD ["run", "dev"]
### Frontend Build ###
#----------------------
FROM ui-base AS ui-build-env
# Copy the rest of the code
COPY ./frontend /app
# Build the frontend
RUN yarn build
### Production Image ###
#-----------------------
FROM alpine:3.17
RUN apk --update add --no-cache ca-certificates
COPY --from=api-build-env /helix /helix
COPY --from=ui-build-env /app/dist /www
ENV FRONTEND_URL=/www
EXPOSE 80
ENTRYPOINT ["/helix", "serve"]