Skip to content
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

chore: inheriting proxy env vars from host when building with docker #2192

Merged
merged 2 commits into from
Oct 13, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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: 11 additions & 2 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
# global args that are used across multiple stages
ARG PROFILE
ARG HTTP_PROXY

# ==========================
# stage 1: build
# https://hub.docker.com/_/rust
# our host is based on bullseye/sid (ubuntu 20)
# ==========================
FROM rust:bullseye as builder
ENV HTTP_PROXY=$HTTP_PROXY
ENV HTTPS_PROXY=$HTTP_PROXY
ENV http_proxy=$HTTP_PROXY
ENV https_proxy=$HTTP_PROXY

WORKDIR /litentry
COPY . /litentry
Expand All @@ -22,6 +27,10 @@ RUN cargo build --locked --profile $PROFILE $BUILD_ARGS
# stage 2: packaging
# ==========================
FROM ubuntu:20.04
ENV HTTP_PROXY=$HTTP_PROXY
ENV HTTPS_PROXY=$HTTP_PROXY
ENV http_proxy=$HTTP_PROXY
ENV https_proxy=$HTTP_PROXY
Kailai-Wang marked this conversation as resolved.
Show resolved Hide resolved
LABEL maintainer="Trust Computing GmbH <info@litentry.com>"

ARG PROFILE
Expand All @@ -35,9 +44,9 @@ RUN useradd -m -u 1000 -U -s /bin/sh -d /litentry litentry && \
mkdir -p /data /litentry/.local/share && \
chown -R litentry:litentry /data && \
ln -s /data /litentry/.local/share/litentry-collator && \
# unclutter and minimize the attack surface
# unclutter and minimize the attack surface
rm -rf /usr/bin /usr/sbin && \
# check if executable works in this container
# check if executable works in this container
/usr/local/bin/litentry-collator --version

USER litentry
Expand Down
3 changes: 3 additions & 0 deletions scripts/build-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ echo "Building ${GITUSER}/${GITREPO}:${TAG} docker image ..."
docker build ${NOCACHE_FLAG} --pull -f ./docker/Dockerfile \
--build-arg PROFILE="$PROFILE" \
--build-arg BUILD_ARGS="$ARGS" \
--build-arg HTTP_PROXY="${HTTP_PROXY//localhost/host.docker.internal}" \
--add-host=host.docker.internal:host-gateway \
--network host \
Kailai-Wang marked this conversation as resolved.
Show resolved Hide resolved
-t ${GITUSER}/${GITREPO}:${TAG} .

# Tag it with latest if no tag parameter was provided
Expand Down