roulette/docker/Dockerfile.debug

39 lines
760 B
Docker

# set app name
ARG app=roulette
# create build stage
ARG TAG
FROM --platform=$BUILDPLATFORM golang:$TAG AS build
ARG app
# copy source files into the container
COPY . /src/$app/
# build the binary
WORKDIR /src/$app
ARG TARGETOS TARGETARCH
RUN CGO_ENABLED=0 \
GOOS=$TARGETOS \
GOARCH=$TARGETARCH \
go build -trimpath -tags timetzdata -o $app \
&& chmod 500 $app
# set up final stage
FROM --platform=$BUILDPLATFORM alpine:latest
ARG app
# copy in user info
COPY --chown=root:root --chmod=0400 docker/passwd /etc/passwd
# run as root for debug
USER root
# copy in binary
COPY --from=build --chown=root:root --chmod=0005 /src/$app/$app /$app
# listen on an unprivileged port
EXPOSE 8080
# launch a shell by default
ENTRYPOINT ["/bin/ash"]