2020-08-23 22:05:20 +03:00
|
|
|
# Build the application
|
2021-04-15 20:26:17 +03:00
|
|
|
FROM golang:1.16-alpine AS build
|
2020-08-23 22:05:20 +03:00
|
|
|
RUN apk update && apk upgrade && \
|
2020-08-28 20:56:26 +03:00
|
|
|
apk add --no-cache bash git openssh build-base
|
2020-08-23 22:05:20 +03:00
|
|
|
WORKDIR /app
|
|
|
|
COPY go.mod go.sum ./
|
|
|
|
RUN go mod download
|
|
|
|
COPY . .
|
|
|
|
RUN go build \
|
|
|
|
-o pasty \
|
|
|
|
-ldflags "\
|
2021-04-15 20:26:17 +03:00
|
|
|
-X github.com/lus/pasty/internal/static.Version=$(git rev-parse --abbrev-ref HEAD)-$(git describe --tags --abbrev=0)-$(git log --pretty=format:'%h' -n 1)" \
|
2020-08-23 22:05:20 +03: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/
|
|
|
|
CMD ["./pasty"]
|