-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
44 lines (32 loc) · 957 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
41
42
43
44
# build standalone docker container
#install certs
FROM ubuntu:latest AS ubuntu
RUN apt-get update
RUN apt-get install ca-certificates -y
RUN update-ca-certificates
# Build node modules
FROM node:22 AS nodebuilder
COPY . /home/node/app
WORKDIR /home/node/app
RUN npm i
RUN npm run build
# Start from the latest golang base image
FROM golang:1.23 AS golangbuilder
COPY . /go/src/gocook
WORKDIR /go/src/gocook
# copy static files
COPY --from=nodebuilder /home/node/app/web/static/css/ web/static/css/
COPY --from=nodebuilder /home/node/app/web/static/fonts/ web/static/fonts/
RUN go mod download
RUN go build -a -tags netgo -v -ldflags '-w -extldflags "-static"' -o /go/bin ./cmd/server
FROM scratch
# copy cert files
WORKDIR /etc/ssl/certs
COPY --from=ubuntu /etc/ssl/certs .
# target gocook directory in image
WORKDIR /gocook
# copy go binary and templates
COPY --from=golangbuilder /go/bin .
ENV GIN_MODE=release
EXPOSE 8080
CMD ["./server"]