From cf72f9ff118b4c83f58426dcffd8d2b897278d5f Mon Sep 17 00:00:00 2001 From: lbesnard Date: Tue, 5 Nov 2024 13:45:15 +1100 Subject: [PATCH 1/2] Update Dockerfile --- Dockerfile | 38 +++++++++++++++++++++++++------------- docker-compose.yml | 16 ++++++++++++++++ 2 files changed, 41 insertions(+), 13 deletions(-) create mode 100644 docker-compose.yml diff --git a/Dockerfile b/Dockerfile index 2904d80..2dd8b83 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,15 @@ FROM python:3.12-slim # Set environment variables for Poetry -ENV POETRY_VERSION=1.6.1 \ - POETRY_VIRTUALENVS_CREATE=true \ - POETRY_VIRTUALENVS_IN_PROJECT=true \ - POETRY_HOME="/opt/poetry" +ENV POETRY_VERSION=1.8.4 +ENV POETRY_HOME=/opt/poetry +ENV POETRY_NO_INTERACTION=1 +ENV POETRY_VIRTUALENVS_IN_PROJECT=1 +ENV POETRY_VIRTUALENVS_CREATE=1 +ENV PYTHONDONTWRITEBYTECODE=1 +ENV PYTHONUNBUFFERED=1 +ENV VIRTUAL_ENV=/app/.venv +ENV PATH="${VIRTUAL_ENV}/bin:$PATH" # Install Poetry and dependencies RUN apt-get update && apt-get install -y curl && \ @@ -14,17 +19,24 @@ RUN apt-get update && apt-get install -y curl && \ # Set the working directory WORKDIR /app -COPY poetry.lock pyproject.toml /app/ +COPY . /app +#COPY poetry.lock pyproject.toml /app/ # Install dependencies -RUN poetry install --no-interaction --no-root +RUN poetry install --with dev --no-interaction # --no-root -COPY . /app -# Install the project -RUN poetry install --no-interaction +# Enable bash-completion and set bash as the default shell +RUN echo "alias ll='ls -la'" >> ~/.bashrc && \ + echo "alias poetry='poetry run'" >> ~/.bashrc +## Run tests and verify the package build +#RUN poetry run pytest && \ + #poetry build && \ + #pip install dist/*.whl + +# Configure the shell to automatically activate the venv +RUN echo "source ${VIRTUAL_ENV}/bin/activate" >> ~/.bashrc + +#ENTRYPOINT ["bash"] -# Run tests and verify the package build -RUN poetry run pytest && \ - poetry build && \ - pip install dist/*.whl +CMD ["/usr/bin/bash"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..ca7c5db --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,16 @@ +services: + aodn_cloud_optimised: + container_name: aodn_cloud_optimised + build: + context: . + dockerfile: Dockerfile + ports: + - "8284:80" + volumes: + - ${PWD}:/app/shared + - $HOME/.aws:/root/.aws:ro # Mount the .aws directory in read-only mode + #- /tmp/aodn_cloud_optimised/config:/app/aodn_cloud_optimised/config # Mount config folder + environment: + - AWS_PROFILE=${AWS_PROFILE} + stdin_open: true # Keep STDIN open for interactive sessions + tty: true From 06d32bce26a41ef59688f2539a4709a9da031149 Mon Sep 17 00:00:00 2001 From: lbesnard Date: Tue, 5 Nov 2024 13:46:59 +1100 Subject: [PATCH 2/2] Update Dockerfile build on release --- .github/workflows/docker.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml index 3c38355..30cdd6b 100644 --- a/.github/workflows/docker.yaml +++ b/.github/workflows/docker.yaml @@ -7,6 +7,8 @@ on: pull_request: branches: - main + release: + types: [created] jobs: build: