-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
34 lines (25 loc) · 642 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
FROM docker.io/library/golang:alpine AS base
# set Go envvars
ENV GO111MODULE=on \
CGO_ENABLED=0 \
GOOS=linux \
GOARCH=amd64
# set code location and build app
WORKDIR /app
ADD src/ /app
RUN go build -o app
# Deploy: Copy apps into deployment container
FROM alpine
RUN adduser -DH user
WORKDIR /tmp
COPY --from=base /app/app /usr/local/bin
COPY --chown=user:users id_rsa /srv/id_rsa
COPY --chown=user:users id_rsa.pub /srv/id_rsa.pub
# Run as non-root user
RUN chmod +x /usr/local/bin/app
RUN chown user:users /usr/local/bin/app
# set environment variables
ENV PORT=2222
# set user for app
USER user
CMD /usr/local/bin/app