FROM docker.io/golang:alpine as go RUN apk add make 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 make -C rex_server # 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/rex_server/rexserver rexserver EXPOSE 8080 USER nonroot:nonroot CMD ["./rexserver"]