Better Dockerfile (#645)
* Add support for docker compose build * Avoid copying more file than needed * Reduce Docker image size
This commit is contained in:
parent
08bbb1537e
commit
e905e5de53
33
Dockerfile
33
Dockerfile
@ -4,31 +4,36 @@
|
||||
FROM golang:1.19-bullseye AS build
|
||||
|
||||
WORKDIR /build
|
||||
ADD . /build
|
||||
|
||||
RUN git config --global --add safe.directory /build
|
||||
COPY go.mod go.sum ./
|
||||
RUN go mod download
|
||||
COPY Makefile main.go ./
|
||||
COPY static/ static/
|
||||
COPY pkg/ pkg/
|
||||
COPY .git/ .
|
||||
RUN make build
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Fetch signing key
|
||||
# ------------------------------------------------------------------------------
|
||||
FROM debian:bullseye-slim AS keyring
|
||||
ADD https://www.postgresql.org/media/keys/ACCC4CF8.asc keyring.asc
|
||||
RUN apt-get update && \
|
||||
apt-get install -qq --no-install-recommends gpg
|
||||
RUN gpg -o keyring.pgp --dearmor keyring.asc
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Release Stage
|
||||
# ------------------------------------------------------------------------------
|
||||
FROM debian:bullseye-slim
|
||||
|
||||
RUN \
|
||||
ARG keyring=/usr/share/keyrings/postgresql-archive-keyring.pgp
|
||||
COPY --from=keyring /keyring.pgp $keyring
|
||||
RUN . /etc/os-release && \
|
||||
echo "deb [signed-by=${keyring}] http://apt.postgresql.org/pub/repos/apt/ ${VERSION_CODENAME}-pgdg main" > /etc/apt/sources.list.d/pgdg.list && \
|
||||
apt-get update && \
|
||||
apt-get install -y ca-certificates openssl netcat curl gnupg lsb-release && \
|
||||
update-ca-certificates
|
||||
|
||||
RUN \
|
||||
curl --silent https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add && \
|
||||
echo "deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" | tee /etc/apt/sources.list.d/pgdg.list && \
|
||||
apt-get update && apt-get install -y postgresql-client
|
||||
|
||||
RUN \
|
||||
apt-get clean autoclean && \
|
||||
apt-get autoremove --yes && \
|
||||
rm -rf /var/lib/{apt,dpkg,cache,log}/
|
||||
apt-get install -qq --no-install-recommends ca-certificates openssl netcat curl postgresql-client
|
||||
|
||||
COPY --from=build /build/pgweb /usr/bin/pgweb
|
||||
|
||||
|
@ -22,6 +22,7 @@ services:
|
||||
pgweb:
|
||||
container_name: pgweb
|
||||
image: sosedoff/pgweb:latest
|
||||
build: .
|
||||
environment:
|
||||
PGWEB_DATABASE_URL: postgres://pgweb:pgweb@pgweb-postgres:5432/pgweb?sslmode=disable
|
||||
ports:
|
||||
|
Loading…
x
Reference in New Issue
Block a user