Containerfile and build target
This commit is contained in:
parent
711f1a1f3a
commit
0676495d0f
2 changed files with 29 additions and 1 deletions
24
container/Containerfile
Normal file
24
container/Containerfile
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
FROM docker.io/golang:alpine as go
|
||||
WORKDIR /build
|
||||
# ADD rex_server/go.mod rex_server/go.sum ./ # WARNING: Include go.sum
|
||||
ADD rex_server/go.mod ./
|
||||
|
||||
RUN go mod download
|
||||
|
||||
# Add the rest of the source
|
||||
ADD . .
|
||||
|
||||
RUN go build -o ./rexserver ./rex_server/server.go
|
||||
|
||||
# Runner image, drop privileges
|
||||
FROM docker.io/alpine:latest as runner
|
||||
RUN adduser -D nonroot
|
||||
RUN addgroup nonroot nonroot
|
||||
WORKDIR /app
|
||||
RUN chown nonroot:nonroot /app
|
||||
|
||||
COPY --from=go /build/rexserver rexserver
|
||||
EXPOSE 8080
|
||||
USER nonroot:nonroot
|
||||
CMD ["./rexserver"]
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue