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
35
Dockerfile
35
Dockerfile
@ -4,31 +4,36 @@
|
|||||||
FROM golang:1.19-bullseye AS build
|
FROM golang:1.19-bullseye AS build
|
||||||
|
|
||||||
WORKDIR /build
|
WORKDIR /build
|
||||||
ADD . /build
|
|
||||||
|
|
||||||
RUN git config --global --add safe.directory /build
|
RUN git config --global --add safe.directory /build
|
||||||
|
COPY go.mod go.sum ./
|
||||||
RUN go mod download
|
RUN go mod download
|
||||||
|
COPY Makefile main.go ./
|
||||||
|
COPY static/ static/
|
||||||
|
COPY pkg/ pkg/
|
||||||
|
COPY .git/ .
|
||||||
RUN make build
|
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
|
# Release Stage
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
FROM debian:bullseye-slim
|
FROM debian:bullseye-slim
|
||||||
|
|
||||||
RUN \
|
ARG keyring=/usr/share/keyrings/postgresql-archive-keyring.pgp
|
||||||
apt-get update && \
|
COPY --from=keyring /keyring.pgp $keyring
|
||||||
apt-get install -y ca-certificates openssl netcat curl gnupg lsb-release && \
|
RUN . /etc/os-release && \
|
||||||
update-ca-certificates
|
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 && \
|
||||||
RUN \
|
apt-get install -qq --no-install-recommends ca-certificates openssl netcat curl postgresql-client
|
||||||
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}/
|
|
||||||
|
|
||||||
COPY --from=build /build/pgweb /usr/bin/pgweb
|
COPY --from=build /build/pgweb /usr/bin/pgweb
|
||||||
|
|
||||||
|
@ -22,6 +22,7 @@ services:
|
|||||||
pgweb:
|
pgweb:
|
||||||
container_name: pgweb
|
container_name: pgweb
|
||||||
image: sosedoff/pgweb:latest
|
image: sosedoff/pgweb:latest
|
||||||
|
build: .
|
||||||
environment:
|
environment:
|
||||||
PGWEB_DATABASE_URL: postgres://pgweb:pgweb@pgweb-postgres:5432/pgweb?sslmode=disable
|
PGWEB_DATABASE_URL: postgres://pgweb:pgweb@pgweb-postgres:5432/pgweb?sslmode=disable
|
||||||
ports:
|
ports:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user