roulette/docker/Dockerfile.debug

39 lines
760 B
Docker
Raw Normal View History

2024-01-15 17:10:15 +00:00
# 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/
2024-01-15 17:10:15 +00:00
# build the binary
2024-01-15 17:10:15 +00:00
WORKDIR /src/$app
ARG TARGETOS TARGETARCH
RUN CGO_ENABLED=0 \
GOOS=$TARGETOS \
GOARCH=$TARGETARCH \
go build -trimpath -tags timetzdata -o $app \
2024-01-15 17:10:15 +00:00
&& 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
2024-01-15 17:10:15 +00:00
2024-01-15 18:29:26 +00:00
# run as root for debug
2024-01-15 17:11:19 +00:00
USER root
2024-01-15 17:10:15 +00:00
# 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
2024-01-15 17:10:15 +00:00
ENTRYPOINT ["/bin/ash"]