pasty/Dockerfile

26 lines
602 B
Docker
Raw Permalink Normal View History

2021-04-18 19:31:07 +00:00
# Choose the golang image as the build base image
2021-04-15 17:26:17 +00:00
FROM golang:1.16-alpine AS build
2021-04-18 19:31:07 +00:00
# Define the directory we should work in
2020-08-23 19:05:20 +00:00
WORKDIR /app
2021-04-18 19:31:07 +00:00
# Download the necessary go modules
2020-08-23 19:05:20 +00:00
COPY go.mod go.sum ./
RUN go mod download
2021-04-18 19:31:07 +00:00
# Build the application
ARG PASTY_VERSION=unset-debug
2020-08-23 19:05:20 +00:00
COPY . .
RUN go build \
-o pasty \
-ldflags "\
2021-04-18 19:31:07 +00:00
-X github.com/lus/pasty/internal/static.Version=$PASTY_VERSION" \
2020-08-23 19:05:20 +00:00
./cmd/pasty/main.go
# Run the application in an empty alpine environment
FROM alpine:latest
WORKDIR /root
COPY --from=build /app/pasty .
COPY web ./web/
EXPOSE 8080
2020-08-23 19:05:20 +00:00
CMD ["./pasty"]