2021-04-18 22:31:07 +03:00
|
|
|
# Choose the golang image as the build base image
|
2021-04-15 20:26:17 +03:00
|
|
|
FROM golang:1.16-alpine AS build
|
2021-04-18 22:31:07 +03:00
|
|
|
|
|
|
|
# Define the directory we should work in
|
2020-08-23 22:05:20 +03:00
|
|
|
WORKDIR /app
|
2021-04-18 22:31:07 +03:00
|
|
|
|
|
|
|
# Download the necessary go modules
|
2020-08-23 22:05:20 +03:00
|
|
|
COPY go.mod go.sum ./
|
|
|
|
RUN go mod download
|
2021-04-18 22:31:07 +03:00
|
|
|
|
|
|
|
# Build the application
|
|
|
|
ARG PASTY_VERSION=unset-debug
|
2020-08-23 22:05:20 +03:00
|
|
|
COPY . .
|
2022-04-18 21:06:36 +03:00
|
|
|
ENV CGO_ENABLED=0
|
2020-08-23 22:05:20 +03:00
|
|
|
RUN go build \
|
|
|
|
-o pasty \
|
|
|
|
-ldflags "\
|
2021-04-18 22:31:07 +03:00
|
|
|
-X github.com/lus/pasty/internal/static.Version=$PASTY_VERSION" \
|
2020-08-23 22:05:20 +03:00
|
|
|
./cmd/pasty/main.go
|
|
|
|
|
2022-04-18 21:06:36 +03:00
|
|
|
# Run the application on distroless
|
|
|
|
FROM gcr.io/distroless/base:latest
|
2020-08-23 22:05:20 +03:00
|
|
|
WORKDIR /root
|
|
|
|
COPY --from=build /app/pasty .
|
2023-06-08 20:17:34 +03:00
|
|
|
COPY internal/web/web ./web/
|
2021-12-19 15:24:53 +03:00
|
|
|
EXPOSE 8080
|
2020-08-23 22:05:20 +03:00
|
|
|
CMD ["./pasty"]
|