-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile
46 lines (35 loc) · 994 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
45
46
#######################
##### BUILD STAGE #####
#######################
FROM golang:1.20-alpine AS build_stage
# This can't be `/workspace` or kaniko in cloud build breaks
WORKDIR /app
# We want to populate the module cache based on the go.{mod,sum} files.
COPY go.mod .
COPY go.sum .
RUN go mod download
RUN mkdir cmd
RUN mkdir cmd/llproxy
COPY cmd/llproxy/ cmd/llproxy/
# Build the Go app
RUN GOOS=linux GOARCH=amd64 go build ./cmd/llproxy
RUN adduser --disabled-password --shell /bin/ash llp
USER llp
# Unit tests
COPY test.sh .
RUN ./test.sh
#########################
##### RUNTIME STAGE #####
#########################
FROM alpine:3.18
# Create user so we don't run as root
RUN addgroup --gid 1000 llp && \
adduser --disabled-password --uid 1000 --ingroup llp --shell /bin/ash --home /home/llp llp
USER llp
WORKDIR /home/llp/
# Copy binary from build stage
COPY --chown=1000:1000 --from=build_stage /app/llproxy .
COPY config.json .
EXPOSE 8080
EXPOSE 8081
CMD [ "./llproxy" ]