From 0560372b675e5776128b715dede84189621a5f91 Mon Sep 17 00:00:00 2001 From: Tasko Olevski Date: Tue, 16 May 2023 17:29:53 +0200 Subject: [PATCH] squashme: fix docker builds --- Dockerfile | 21 ++++++++++----------- git_services/Dockerfile.init | 13 ++++++------- git_services/Dockerfile.sidecar | 15 +++++++-------- 3 files changed, 23 insertions(+), 26 deletions(-) diff --git a/Dockerfile b/Dockerfile index cd1a5e133..6fed0ad75 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,27 +1,26 @@ FROM python:3.11-bullseye as builder RUN groupadd --gid 1000 renku && \ - adduser --gid 1000 --uid 1000 renku + useradd --gid 1000 --uid 1000 --create-home renku USER 1000:1000 -WORKDIR /app +WORKDIR /home/renku/app RUN python3 -m pip install --user pipx && \ python3 -m pipx ensurepath && \ - /home/renku/.local/bin/pipx install poetry -RUN /home/renku/.local/bin/poetry config virtualenvs.in-project true && \ - /home/renku/.local/bin/poetry config virtualenvs.options.no-setuptools true && \ - /home/renku/.local/bin/poetry config virtualenvs.options.no-pip true + /home/renku/.local/bin/pipx install poetry && \ + python3 -m venv .env COPY poetry.lock pyproject.toml ./ -RUN /home/renku/.local/bin/poetry install --only main --no-root +RUN /home/renku/.local/bin/poetry export --only main --without-hashes -o requirements.txt && \ + .env/bin/pip install -r requirements.txt --prefer-binary FROM python:3.11-slim-bullseye RUN apt-get update && apt-get install -y \ tini curl && \ rm -rf /var/lib/apt/lists/* && \ groupadd --gid 1000 renku && \ - adduser --gid 1000 --uid 1000 renku + useradd --gid 1000 --uid 1000 --create-home renku USER 1000:1000 -WORKDIR /app -COPY --from=builder /app/.venv .venv +WORKDIR /home/renku/app +COPY --from=builder /home/renku/app/.env .env COPY renku_notebooks renku_notebooks COPY resource_schema_migrations resource_schema_migrations ENTRYPOINT ["tini", "-g", "--"] -CMD [".venv/bin/gunicorn", "-b 0.0.0.0:8000", "renku_notebooks.wsgi:app", "-k gevent"] +CMD [".env/bin/gunicorn", "-b 0.0.0.0:8000", "renku_notebooks.wsgi:app", "-k gevent"] diff --git a/git_services/Dockerfile.init b/git_services/Dockerfile.init index 526ae1630..84983b8b5 100644 --- a/git_services/Dockerfile.init +++ b/git_services/Dockerfile.init @@ -1,13 +1,12 @@ FROM python:3.10-bullseye as builder RUN groupadd --gid 1000 renku && \ - adduser --gid 100 --gid 1000 --uid 1000 jovyan + useradd --gid 100 --gid 1000 --uid 1000 --create-home jovyan USER 1000:1000 -WORKDIR /app +WORKDIR /home/jovyan/app RUN python3 -m pip install --user pipx && \ python3 -m pipx ensurepath && \ /home/jovyan/.local/bin/pipx install poetry && \ - /home/jovyan/.local/bin/pipx install virtualenv && \ - /home/jovyan/.local/bin/virtualenv .env + python3 -m venv .env COPY poetry.lock pyproject.toml ./ RUN /home/jovyan/.local/bin/poetry export --only main --without-hashes -o requirements.txt && \ .env/bin/pip install -r requirements.txt --prefer-binary @@ -17,10 +16,10 @@ RUN apt-get update && apt-get install -y \ tini curl git git-lfs && \ rm -rf /var/lib/apt/lists/* && \ groupadd --gid 1000 renku && \ - adduser --gid 100 --gid 1000 --uid 1000 jovyan + useradd --gid 100 --gid 1000 --uid 1000 --create-home jovyan USER 1000:1000 -WORKDIR /app -COPY --from=builder /app/.env .env +WORKDIR /home/jovyan/app +COPY --from=builder /home/jovyan/app/.env .env ADD git_services ./git_services ENTRYPOINT ["tini", "-g", "--"] CMD [".env/bin/python3", "-m", "git_services.init.clone"] diff --git a/git_services/Dockerfile.sidecar b/git_services/Dockerfile.sidecar index 97130d92f..246d6f967 100644 --- a/git_services/Dockerfile.sidecar +++ b/git_services/Dockerfile.sidecar @@ -1,13 +1,12 @@ FROM python:3.10-bullseye as builder RUN groupadd --gid 1000 renku && \ - adduser --gid 100 --gid 1000 --uid 1000 jovyan + useradd --gid 100 --gid 1000 --uid 1000 --create-home jovyan USER 1000:1000 -WORKDIR /app +WORKDIR /home/jovyan/app RUN python3 -m pip install --user pipx && \ python3 -m pipx ensurepath && \ /home/jovyan/.local/bin/pipx install poetry && \ - /home/jovyan/.local/bin/pipx install virtualenv && \ - /home/jovyan/.local/bin/virtualenv .env + python3 -m venv .env COPY poetry.lock pyproject.toml ./ RUN /home/jovyan/.local/bin/poetry export --only main --without-hashes -o requirements.txt && \ .env/bin/pip install -r requirements.txt --prefer-binary @@ -17,11 +16,11 @@ RUN apt-get update && apt-get install -y \ tini curl git git-lfs && \ rm -rf /var/lib/apt/lists/* && \ groupadd --gid 1000 renku && \ - adduser --gid 100 --gid 1000 --uid 1000 jovyan + useradd --gid 100 --gid 1000 --uid 1000 --create-home jovyan USER 1000:1000 -WORKDIR /app -COPY --from=builder /app/.env .env +WORKDIR /home/jovyan/app +COPY --from=builder /home/jovyan/app/.env .env ADD git_services ./git_services -ENV PATH="${PATH}:/git_services/.venv/bin" +ENV PATH="${PATH}:/home/jovyan/app/.env/bin" ENTRYPOINT ["tini", "-g", "--"] CMD [".env/bin/gunicorn", "-c", "git_services/sidecar/gunicorn.conf.py"]