mirror of
https://github.com/Maronato/go-finger.git
synced 2025-03-14 16:24:48 +00:00
54 lines
1.1 KiB
Docker
54 lines
1.1 KiB
Docker
# Load golang image
|
|
FROM golang:1.21-alpine as builder
|
|
|
|
RUN apk add make
|
|
|
|
ARG VERSION=undefined
|
|
|
|
WORKDIR /go/src/app
|
|
|
|
# Set our build environment
|
|
ENV GOCACHE=/tmp/.go-build-cache
|
|
# This variable communicates to the service that it's running inside
|
|
# a docker container.
|
|
ENV ENV_DOCKER=true
|
|
|
|
# Copy dockerignore files
|
|
COPY .dockerignore ./
|
|
|
|
# Install go deps using the cache
|
|
COPY go.mod go.sum ./
|
|
RUN --mount=type=cache,target=/tmp/.go-build-cache \
|
|
go mod download -x
|
|
|
|
COPY Makefile ./
|
|
|
|
# Copy source files
|
|
COPY main.go ./
|
|
COPY cmd cmd
|
|
COPY internal internal
|
|
COPY webfingers webfingers
|
|
COPY handler handler
|
|
|
|
# Build it
|
|
RUN --mount=type=cache,target=/tmp/.go-build-cache \
|
|
make build VERSION=$VERSION
|
|
|
|
# Now create a new image with just the binary
|
|
FROM gcr.io/distroless/static-debian11:nonroot
|
|
|
|
WORKDIR /app
|
|
|
|
COPY urns.yml /app/urns.yml
|
|
|
|
# Set our runtime environment
|
|
ENV ENV_DOCKER=true
|
|
|
|
COPY --from=builder /go/src/app/finger /usr/local/bin/finger
|
|
|
|
HEALTHCHECK CMD [ "finger", "healthcheck" ]
|
|
|
|
EXPOSE 8080
|
|
|
|
ENTRYPOINT [ "finger" ]
|
|
CMD [ "serve" ]
|