Docker build refactor (#568)

This commit is contained in:
Dan Sosedoff
2022-06-27 22:31:57 -05:00
committed by GitHub
parent 193073727a
commit ae3b74ad2a
6 changed files with 148 additions and 13 deletions

View File

@@ -1,17 +1,29 @@
FROM alpine:3.15
LABEL maintainer="Dan Sosedoff <dan.sosedoff@gmail.com>"
ENV PGWEB_VERSION 0.11.11
# ------------------------------------------------------------------------------
# Builder Stage
# ------------------------------------------------------------------------------
FROM golang:1.18-buster AS build
WORKDIR /build
ADD . /build
RUN go mod download
RUN make build
# ------------------------------------------------------------------------------
# Release Stage
# ------------------------------------------------------------------------------
FROM debian:buster-slim
RUN \
apk update && \
apk add --no-cache ca-certificates openssl postgresql wget && \
apt-get update && \
apt-get install -y ca-certificates openssl postgresql && \
update-ca-certificates && \
rm -rf /var/cache/apk/* && \
cd /tmp && \
wget -q https://github.com/sosedoff/pgweb/releases/download/v$PGWEB_VERSION/pgweb_linux_amd64.zip && \
unzip pgweb_linux_amd64.zip -d /usr/bin && \
mv /usr/bin/pgweb_linux_amd64 /usr/bin/pgweb && \
rm -f pgweb_linux_amd64.zip
apt-get clean autoclean && \
apt-get autoremove --yes && \
rm -rf /var/lib/{apt,dpkg,cache,log}/
COPY --from=build /build/pgweb /usr/bin/pgweb
EXPOSE 8081
CMD ["/usr/bin/pgweb", "--bind=0.0.0.0", "--listen=8081"]