Docker: build rest-server at container build time

Using docker's multi-stage builds we can build the restic/rest-server
within a golang build environment then create a container for use
(without the build environment) in a second build stage.

The advantages are:

1. Building the rest-server is predictable in a pristine environment
   each time.
2. Container builds ensure we get the latest rest-server every time.

Updated README with details of new docker build approach, and added
changelog for unreleased changes.
This commit is contained in:
Jinn Koriech
2021-03-25 08:56:55 +00:00
parent 10dc7a4a86
commit 3a4d901f6d
3 changed files with 23 additions and 2 deletions

View File

@@ -1,3 +1,14 @@
FROM golang:alpine AS builder
ENV CGO_ENABLED 0
COPY . /build
WORKDIR /build
RUN go build -o rest-server ./cmd/rest-server
FROM alpine
ENV DATA_DIRECTORY /data
@@ -8,7 +19,7 @@ RUN apk add --no-cache --update apache2-utils
COPY docker/create_user /usr/bin/
COPY docker/delete_user /usr/bin/
COPY docker/entrypoint.sh /entrypoint.sh
COPY rest-server /usr/bin
COPY --from=builder /build/rest-server /usr/bin
VOLUME /data
EXPOSE 8000