Make tiny containers
Base the container on scratch and build a static binary
This commit is contained in:
parent
65cac0d308
commit
8d4e9ebc88
17
Dockerfile
17
Dockerfile
|
@ -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"]
|
||||
|
|
2
Makefile
2
Makefile
|
@ -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 ./...
|
||||
|
|
Loading…
Reference in a new issue