Skip to content

Commit

Permalink
Merge ebb21cd into 0573564
Browse files Browse the repository at this point in the history
  • Loading branch information
dennisschagt committed Mar 10, 2024
2 parents 0573564 + ebb21cd commit 58a845d
Show file tree
Hide file tree
Showing 6 changed files with 109 additions and 25 deletions.
10 changes: 10 additions & 0 deletions docker/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

USER_ID=${HOST_UID:-1000}
GROUP_ID=${HOST_GID:-1000}

echo "Starting with UID: $USER_ID, GID: $GROUP_ID"
usermod -u $USER_ID builder
groupmod -g $GROUP_ID builder

exec /usr/sbin/gosu builder "$@"
16 changes: 11 additions & 5 deletions docker/ubuntu_18.04-build-tools.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@
#
# docker run \
# --rm \
# --mount type=bind,source=$(pwd),target=/home/builder/src \
# --user $(id -u):$(id -g) \
# --mount type=bind,source=$(pwd),target=/src \
# -e HOST_UID=$(id -u) \
# -e HOST_GID=$(id -g) \
# newsboat-build-tools \
# make
#
Expand Down Expand Up @@ -69,14 +70,14 @@ RUN apt-get update \
&& apt-get install --assume-yes --no-install-recommends \
build-essential $cxx_package libsqlite3-dev libcurl4-openssl-dev libssl-dev \
libxml2-dev libstfl-dev libjson-c-dev libncursesw5-dev gettext git \
asciidoctor wget \
asciidoctor wget gosu \
&& apt-get autoremove \
&& apt-get clean

RUN addgroup --gid 1000 builder \
&& adduser --home /home/builder --uid 1000 --ingroup builder \
--disabled-password --shell /bin/bash builder \
&& mkdir -p /home/builder/src \
&& mkdir -p /src \
&& chown -R builder:builder /home/builder

RUN apt-get install locales \
Expand All @@ -89,7 +90,7 @@ ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8

USER builder
WORKDIR /home/builder/src
WORKDIR /src

ARG rust_version=1.76.0

Expand All @@ -107,3 +108,8 @@ ARG cxx=g++-8

ENV CC=$cc
ENV CXX=$cxx

USER root
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
RUN chmod +x /usr/local/bin/entrypoint.sh
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
16 changes: 11 additions & 5 deletions docker/ubuntu_18.04-i686.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@
#
# docker run \
# --rm \
# --mount type=bind,source=$(pwd),target=/home/builder/src \
# --user $(id -u):$(id -g) \
# --mount type=bind,source=$(pwd),target=/src \
# -e HOST_UID=$(id -u) \
# -e HOST_GID=$(id -g) \
# newsboat-i686-build-tools \
# make
#
Expand Down Expand Up @@ -54,15 +55,15 @@ RUN apt-get update \
# `curl` would be enough for our needs, but it pulls in amd64 versions
# of libraries we use, interfering with the build environment. So
# `wget` it is.
wget \
wget gosu \
&& apt-get install --assume-yes --no-install-recommends asciidoctor \
&& apt-get autoremove \
&& apt-get clean

RUN addgroup --gid 1000 builder \
&& adduser --home /home/builder --uid 1000 --ingroup builder \
--disabled-password --shell /bin/bash builder \
&& mkdir -p /home/builder/src \
&& mkdir -p /src \
&& chown -R builder:builder /home/builder

RUN apt-get update \
Expand All @@ -76,7 +77,7 @@ ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8

USER builder
WORKDIR /home/builder/src
WORKDIR /src

RUN wget -O $HOME/rustup.sh --secure-protocol=TLSv1_2 https://sh.rustup.rs \
&& chmod +x $HOME/rustup.sh \
Expand All @@ -86,3 +87,8 @@ RUN wget -O $HOME/rustup.sh --secure-protocol=TLSv1_2 https://sh.rustup.rs \
&& chmod a+w $HOME/.cargo

ENV HOME /home/builder

USER root
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
RUN chmod +x /usr/local/bin/entrypoint.sh
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
16 changes: 11 additions & 5 deletions docker/ubuntu_20.04-build-tools.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@
#
# docker run \
# --rm \
# --mount type=bind,source=$(pwd),target=/home/builder/src \
# --user $(id -u):$(id -g) \
# --mount type=bind,source=$(pwd),target=/src \
# -e HOST_UID=$(id -u) \
# -e HOST_GID=$(id -g) \
# newsboat-build-tools \
# make
#
Expand Down Expand Up @@ -69,14 +70,14 @@ RUN apt-get update \
&& apt-get install --assume-yes --no-install-recommends \
build-essential $cxx_package libsqlite3-dev libcurl4-openssl-dev libssl-dev \
libxml2-dev libstfl-dev libjson-c-dev libncursesw5-dev gettext git \
pkg-config zlib1g-dev asciidoctor wget \
pkg-config zlib1g-dev asciidoctor wget gosu \
&& apt-get autoremove \
&& apt-get clean

RUN addgroup --gid 1000 builder \
&& adduser --home /home/builder --uid 1000 --ingroup builder \
--disabled-password --shell /bin/bash builder \
&& mkdir -p /home/builder/src \
&& mkdir -p /src \
&& chown -R builder:builder /home/builder

RUN apt-get install locales \
Expand All @@ -89,7 +90,7 @@ ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8

USER builder
WORKDIR /home/builder/src
WORKDIR /src

ARG rust_version=1.76.0

Expand All @@ -107,3 +108,8 @@ ARG cxx=g++-9

ENV CC=$cc
ENV CXX=$cxx

USER root
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
RUN chmod +x /usr/local/bin/entrypoint.sh
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
16 changes: 11 additions & 5 deletions docker/ubuntu_22.04-build-tools.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@
#
# docker run \
# --rm \
# --mount type=bind,source=$(pwd),target=/home/builder/src \
# --user $(id -u):$(id -g) \
# --mount type=bind,source=$(pwd),target=/src \
# -e HOST_UID=$(id -u) \
# -e HOST_GID=$(id -g) \
# newsboat-build-tools \
# make
#
Expand Down Expand Up @@ -70,14 +71,14 @@ RUN apt-get update \
&& apt-get install --assume-yes --no-install-recommends \
build-essential $cxx_package libsqlite3-dev libcurl4-openssl-dev libssl-dev \
libxml2-dev libstfl-dev libjson-c-dev libncursesw5-dev gettext git \
pkg-config zlib1g-dev asciidoctor \
pkg-config zlib1g-dev asciidoctor gosu \
&& apt-get autoremove \
&& apt-get clean

RUN addgroup --gid 1000 builder \
&& adduser --home /home/builder --uid 1000 --ingroup builder \
--disabled-password --shell /bin/bash builder \
&& mkdir -p /home/builder/src \
&& mkdir -p /src \
&& chown -R builder:builder /home/builder

RUN apt-get install locales \
Expand All @@ -90,7 +91,7 @@ ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8

USER builder
WORKDIR /home/builder/src
WORKDIR /src

ARG rust_version=1.76.0

Expand All @@ -108,3 +109,8 @@ ARG cxx=g++-12

ENV CC=$cc
ENV CXX=$cxx

USER root
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
RUN chmod +x /usr/local/bin/entrypoint.sh
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
60 changes: 55 additions & 5 deletions docker/ubuntu_23.10-build-tools.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,51 @@
# - cxx -- C++ compiler to use. This gets copied into CXX environment variable.
# Default: g++-13
#
# For now, this Dockerfile can only be used in our CI.
# Build with defaults:
#
# docker build \
# --tag=newsboat-build-tools \
# --file=docker/ubuntu_23.10-build-tools.dockerfile \
# docker
#
# Build with non-default compiler and Rust version:
#
# docker build \
# --tag=newsboat-build-tools \
# --file=docker/ubuntu_23.10-build-tools.dockerfile \
# --build-arg cxx_package=clang-16 \
# --build-arg cc=clang-16 \
# --build-arg cxx=clang++-16 \
# --build-arg rust_version=1.76.0 \
# docker
#
# Before building in a container, run this to remove any binaries that you
# might've compiled on your host system (or in another container):
#
# make distclean
#
# Run on your local files:
#
# docker run \
# --rm \
# --mount type=bind,source=$(pwd),target=/src \
# -e HOST_UID=$(id -u) \
# -e HOST_GID=$(id -g) \
# newsboat-build-tools \
# make
#
# To save bandwidth, and speed up the build slightly, share the host's Cargo
# cache with the container:
#
# mkdir -p ~/.cargo/registry
# docker run \
# --mount type=bind,source=$HOME/.cargo/registry,target=/home/builder/.cargo/registry \
# ... # the rest of the options
#
# If you want to build on the host again, run this to remove binary files
# compiled in the container:
#
# make distclean

FROM ubuntu:23.10

Expand All @@ -27,15 +71,16 @@ RUN apt-get update \
&& apt-get install --assume-yes --no-install-recommends \
build-essential $cxx_package libsqlite3-dev libcurl4-openssl-dev libssl-dev \
libxml2-dev libstfl-dev libjson-c-dev libncursesw5-dev gettext git \
pkg-config zlib1g-dev asciidoctor \
pkg-config zlib1g-dev asciidoctor gosu \
&& apt-get autoremove \
&& apt-get clean

RUN addgroup builder \
&& deluser ubuntu \
&& adduser --home /home/builder --ingroup builder \
--disabled-password --shell /bin/bash builder \
&& mkdir -p /home/builder/src \
&& chown -R builder:builder /home/builder
&& mkdir -p /src \
&& chown -R builder:builder /src

RUN apt-get install locales \
&& echo 'en_US.UTF-8 UTF-8' >> /etc/locale.gen \
Expand All @@ -47,7 +92,7 @@ ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8

USER builder
WORKDIR /home/builder/src
WORKDIR /src

ARG rust_version=1.76.0

Expand All @@ -65,3 +110,8 @@ ARG cxx=g++-13

ENV CC=$cc
ENV CXX=$cxx

USER root
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
RUN chmod +x /usr/local/bin/entrypoint.sh
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]

0 comments on commit 58a845d

Please sign in to comment.