Skip to content

Commit

Permalink
Adjust Dockerfile to use with nox -s build_linux.
Browse files Browse the repository at this point in the history
  • Loading branch information
drmikehenry committed May 7, 2024
1 parent 45fd49d commit 4af2577
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 21 deletions.
37 changes: 16 additions & 21 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,47 +1,42 @@
FROM ubuntu:18.04

ENV WORKDIR /src

WORKDIR ${WORKDIR}

RUN apt update \
&& apt install -y \
python3.8 \
libpython3.8 \
python3.8-venv \
python3-pip \
&& true
# && rm -rf /var/lib/apt/lists/*

ARG USER_UID="$UID"
ARG USER_GID="$GID"
ARG USER_HOME=/home/user

RUN groupadd -r user -g "$USER_GID" && \
useradd -r -g user -u "$USER_UID" -m -d "${USER_HOME}" \
-s /bin/bash -c "User" user

USER user
&& rm -rf /var/lib/apt/lists/*

ARG ROMT_PIP_VERSION=24.0
ARG ROMT_PIPX_VERSION=1.5.0
ARG ROMT_POETRY_VERSION=1.8.2
ARG ROMT_POETRY_PLUGIN_EXPORT_VERSION=1.7.1

# Add `~/.local/bin` directory to `PATH` for `pipx` binaries.
ENV PATH="${PATH}:/home/user/.local/bin"
ENV PIPX_HOME=/pipx-lib
ENV PIPX_BIN_DIR=/usr/bin

RUN python3.8 -m venv /tmp/pipx-venv
RUN /tmp/pipx-venv/bin/pip install "pip==$ROMT_PIP_VERSION"
RUN /tmp/pipx-venv/bin/pip install "pipx==$ROMT_PIPX_VERSION"
RUN mkdir -p /home/user/.local/bin \
&& ln -s /tmp/pipx-venv/bin/pipx /home/user/.local/bin/pipx
RUN mkdir -p "$PIPX_HOME" \
&& /tmp/pipx-venv/bin/pipx install "pipx==$ROMT_PIPX_VERSION"

RUN pipx install "poetry==$ROMT_POETRY_VERSION" \
&& pipx inject poetry \
"poetry-plugin-export==$ROMT_POETRY_PLUGIN_EXPORT_VERSION"
RUN poetry config warnings.export false

# Copy in project dependency specification that don't change often; this
# speeds up incremental rebuilding of the container.
COPY pyproject.toml poetry.lock ./
RUN poetry install

COPY README.rst \
maintainer.rst \
noxfile.py \
romt-wrapper.py \
./

# src/ must be mounted.

ENTRYPOINT ["poetry", "run", "nox", "-s", "build"]
20 changes: 20 additions & 0 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,26 @@ def build(s: Session) -> None:
shutil.copy(dist_exe_path, github_exe_path)


@session(venv_backend="none")
def build_linux(s: Session) -> None:
# Remove any stray container if it exists; use
# `success_codes` to prevent `nox` failure if the
# container does not exist and `docker rm` fails.
s.run("docker", "rm", "romt-build", success_codes=[0, 1])
s.run("docker", "build", ".", "-t", "romt-build")
s.run(
"docker",
"run",
"-v",
"./src:/src",
"--name",
"romt-build",
"romt-build",
)
s.run("docker", "cp", "romt-build:/dist/.", "dist/")
s.run("docker", "rm", "romt-build")


@session(venv_backend="none")
def release(s: Session) -> None:
version = get_project_version()
Expand Down

0 comments on commit 4af2577

Please sign in to comment.