From e2fc8881884c1193c2ffedd3dff995beab2240e6 Mon Sep 17 00:00:00 2001 From: jingsam Date: Sun, 7 Aug 2022 21:40:18 +0800 Subject: [PATCH] docker: add alpine dockerfile --- Dockerfile.alpine | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 Dockerfile.alpine diff --git a/Dockerfile.alpine b/Dockerfile.alpine new file mode 100644 index 00000000..1df4912a --- /dev/null +++ b/Dockerfile.alpine @@ -0,0 +1,45 @@ +# Lightweight Alpine-based pg_featureserv Docker Image +# Author: jingsam +FROM golang:1.15.5-alpine3.12 + +# Build ARGS +ARG VERSION="latest-alpine-3.12" + +RUN mkdir /app +ADD . /app/ +WORKDIR /app +RUN go build -v -ldflags "-s -w -X main.programVersion=${VERSION}" + +# Multi-stage build: only copy build result and resources +FROM alpine:3.12 + +ARG VERSION + +LABEL original_developer="Crunchy Data" \ + contributor="jingsam " \ + vendor="Crunchy Data" \ + url="https://crunchydata.com" \ + release="${VERSION}" \ + org.opencontainers.image.vendor="Crunchy Data" \ + os.version="3.12" + +RUN apk --no-cache add ca-certificates +COPY --from=0 /app/pg_featureserv . +COPY --from=0 /app/assets ./assets + +VOLUME ["/config"] +VOLUME ["/assets"] + +USER 1001 +EXPOSE 9000 + +ENTRYPOINT ["/pg_featureserv"] +CMD [] + +# To build and run specific version +# +# export VERSION="latest-alpine-3.12" +# docker build --build-arg VERSION=${VERSION} -t pramsey/pg_featureserv:${VERSION} -f Dockerfile.alpine +# +# Best is to use another PostGIS Docker Container whoose host is reachable from the pg_featureserv Container. +# docker run -dt -e DATABASE_URL=postgres://user:pass@host/dbname -p 9000:9000 pramsey/pg_featureserv:${VERSION}