mirror of
https://github.com/lus/pasty.git
synced 2023-08-10 21:13:09 +03:00
1d2e42b737
* docker: Use distroless Much slimmer, way lesser attack surface Signed-off-by: baalajimaestro <me@baalajimaestro.me> * docker: Disable CGO Isnt needed by our code, and breaks distroless Signed-off-by: baalajimaestro <me@baalajimaestro.me> * Uprev mongodb driver Signed-off-by: baalajimaestro <me@baalajimaestro.me> * tidy go module Co-authored-by: Lukas Schulte Pelkum <kbrt@protonmail.com>
27 lines
619 B
Docker
27 lines
619 B
Docker
# Choose the golang image as the build base image
|
|
FROM golang:1.16-alpine AS build
|
|
|
|
# Define the directory we should work in
|
|
WORKDIR /app
|
|
|
|
# Download the necessary go modules
|
|
COPY go.mod go.sum ./
|
|
RUN go mod download
|
|
|
|
# Build the application
|
|
ARG PASTY_VERSION=unset-debug
|
|
COPY . .
|
|
ENV CGO_ENABLED=0
|
|
RUN go build \
|
|
-o pasty \
|
|
-ldflags "\
|
|
-X github.com/lus/pasty/internal/static.Version=$PASTY_VERSION" \
|
|
./cmd/pasty/main.go
|
|
|
|
# Run the application on distroless
|
|
FROM gcr.io/distroless/base:latest
|
|
WORKDIR /root
|
|
COPY --from=build /app/pasty .
|
|
COPY web ./web/
|
|
EXPOSE 8080
|
|
CMD ["./pasty"] |