8000 feat(container): multi arch build by eagleusb · Pull Request #480 · dimitri/pgcopydb · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat(container): multi arch build #480

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Nov 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
.github

docs/_build

src/bin/pgcopydb/pgcopydb
src/bin/pgcopydb/*.o
src/bin/pgcopydb/*.bc
src/bin/pgcopydb/*.so
src/bin/pgcopydb/*.so.[0-9]
src/bin/pgcopydb/*.so.[0-9].[0-9]
src/bin/pgcopydb/.deps/
**/*.o
**/*.bc
**/*.so*
**/.deps/

# ignore the git version number in release builds
src/bin/pgcopydb/git-version.h
112 changes: 62 additions & 50 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,76 +1,88 @@
#
# syntax=docker/dockerfile:latest
# Define a base image with all our build dependencies.
#
FROM debian:bullseye-slim as build
FROM --platform=${TARGETPLATFORM} debian:11-slim as build

RUN apt-get update \
&& apt-get install -y --no-install-recommends \
# multi-arch
ARG TARGETPLATFORM
ARG TARGETOS
ARG TARGETARCH

RUN dpkg --add-architecture ${TARGETARCH:-arm64} && apt update \
&& apt install -qqy --no-install-recommends \
libncurses-dev \
libxml2-dev \
sudo \
valgrind \
build-essential \
libedit-dev \
libicu-dev \
libkrb5-dev \
libssl-dev \
libedit-dev \
libreadline-dev \
libpam-dev \
zlib1g-dev \
liblz4-dev \
libxml2-dev \
libxslt1-dev \
libselinux1-dev \
libncurses-dev \
libncurses6 \
make \
openssl \
sudo \
tmux \
watch \
libpam-dev \
libpq-dev \
libpq5 \
libreadline-dev \
libselinux1-dev \
libssl-dev \
libxslt1-dev \
lsof \
psmisc \
gdb \
psmisc \
gdb \
strace \
valgrind \
postgresql-common \
libpq5 \
libpq-dev \
postgresql-server-dev-all \
tmux \
watch \
make \
openssl \
postgresql-common \
postgresql-client-common \
&& rm -rf /var/lib/apt/lists/*

RUN adduser --disabled-password --gecos '' docker
RUN adduser docker sudo
postgresql-server-dev-all \
psutils \
tmux \
watch \
zlib1g-dev

WORKDIR /usr/src/pgcopydb

COPY Makefile ./
COPY GIT-VERSION-GEN ./
COPY version ./
COPY ./src/ ./src
COPY . .

RUN make -s clean && make -s -j8 install
RUN make -s clean && make -s -j$(nproc) install

#
# Now the "run" image, as small as possible
#
FROM debian:bullseye-slim as run
FROM --platform=${TARGETPLATFORM} debian:11-slim as run

RUN apt-get update \
&& apt-get install -y --no-install-recommends \
# multi-arch
ARG TARGETPLATFORM
ARG TARGETOS
ARG TARGETARCH

# used to configure Github Packages
LABEL org.opencontainers.image.source https://github.com/dimitri/pgcopydb

RUN dpkg --add-architecture ${TARGETARCH:-arm64} && apt update \
&& apt install -qqy --no-install-suggests --no-install-recommends \
sudo \
passwd \
ca-certificates \
openssl \
sudo \
libpq5 \
lsof \
tmux \
watch \
lsof \
psmisc \
libpq5 \
psmisc \
openssl \
postgresql-common \
postgresql-client \
postgresql-client-common \
postgresql-client-13 \
&& rm -rf /var/lib/apt/lists/*
&& apt clean \
&& rm -rf /var/lib/apt/lists/*

RUN adduser --disabled-password --gecos '' --home /var/lib/postgres docker
RUN adduser docker sudo
RUN useradd -rm -d /var/lib/postgres -s /bin/bash -g postgres -G sudo docker
RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers

COPY --from=build /usr/lib/postgresql/13/bin/pgcopydb /usr/local/bin
COPY --from=build --chmod=755 /usr/lib/postgresql/13/bin/pgcopydb /usr/local/bin

USER docker

ENTRYPOINT []
CMD []
HEALTHCHECK NONE
4 changes: 2 additions & 2 deletions Dockerfile.debian
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ RUN apt-get update \
libkrb5-dev \
zlib1g-dev \
liblz4-dev \
libpq5 \
libpq5 \
libpq-dev \
libzstd-dev \
postgresql-server-dev-all \
postgresql-server-dev-all \
postgresql-common \
postgresql \
python3-sphinx \
Expand Down
0