-
Notifications
You must be signed in to change notification settings - Fork 7
/
Dockerfile
37 lines (29 loc) · 968 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
FROM golang:1.23.1-bullseye AS gobuild
# install dependencies
RUN apt-get update \
&& apt-get install -y --no-install-recommends g++ make gcc git build-essential ca-certificates curl \
&& update-ca-certificates
ENV GO111MODULE=on
WORKDIR /app
COPY go.mod .
COPY go.sum .
RUN go mod download
# static build
ADD . .
ENV GOOS=linux
ENV GOARCH=amd64
RUN go build -a -ldflags '-w -extldflags "-static"' -o main main.go
# copy executable file and certs to a pure container
FROM debian:bullseye
RUN apt-get update \
&& apt-get install -y --no-install-recommends ca-certificates haveged \
&& update-ca-certificates \
&& rm -rf /var/lib/apt/lists/*
COPY --from=gobuild /etc/ssl/certs /etc/ssl/certs
COPY --from=gobuild /app/main /app/go-graphql-srv
WORKDIR /app
RUN chmod +rx -R /app && \
adduser --disabled-password --gecos '' laisky
USER laisky
ENTRYPOINT [ "/app/go-graphql-srv" ]
CMD [ "api", "-c", "/etc/laisky-blog-graphql/settings.yml" ]