Make tiny containers

Base the container on scratch and build a static binary
This commit is contained in:
felix@feldspaten.org 2021-06-18 10:35:56 +02:00
parent 65cac0d308
commit 8d4e9ebc88
Signed by: phoenix
GPG key ID: 31860289A704FB3C
2 changed files with 11 additions and 8 deletions

View file

@ -1,15 +1,16 @@
FROM golang:buster AS build-env
ARG ARCH=
FROM ${ARCH}golang:buster AS build-env
WORKDIR /app
ADD . /app
RUN apt-get update && apt-get upgrade -y
RUN cd /app && make requirements && make -B pastad
#RUN apt-get update && apt-get upgrade -y
RUN cd /app && make requirements && make pastad-static
FROM debian:buster
RUN apt-get update && apt-get upgrade -y
RUN mkdir /app
RUN mkdir /data
FROM scratch
#RUN mkdir /app
#RUN mkdir /data
WORKDIR /data
COPY --from=build-env /app/pastad /app/pastad
COPY --from=build-env /app/mime.types /app/mime.types
ENTRYPOINT /app/pastad -m /app/mime.types -c /data/pastad.toml
ENTRYPOINT ["/app/pastad", "-m", "/app/mime.types", "-c", "/data/pastad.toml"]
VOLUME ["/data"]

View file

@ -11,6 +11,8 @@ pasta: cmd/pasta/pasta.go cmd/pasta/storage.go
go build $^
pastad: cmd/pastad/pastad.go cmd/pastad/storage.go
go build $^
pastad-static: cmd/pastad/pastad.go cmd/pastad/storage.go
CGO_ENABLED=0 go build -ldflags="-w -s" -o pastad $^
test: pastad pasta
go test ./...