Skip to content

Commit

Permalink
Reformat output for information
Browse files Browse the repository at this point in the history
  • Loading branch information
cscollett committed Aug 30, 2024
1 parent df2fe17 commit 5048ffe
Showing 1 changed file with 13 additions and 31 deletions.
44 changes: 13 additions & 31 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@ WORKDIR /app

# Both build and development need poetry, so it is its own step.
FROM base AS poetry

# Print environment information
RUN echo -n "--------START ENVIRONMENT OUTPUT--------"
RUN echo -n "OS: " && cat /etc/os-release
# Print Debian version on the same line
RUN echo -n "FULL OS VERSION: " && hostnamectl | grep "Operating System" | awk '{print $3}'
# Print Python version on the same line
RUN echo -n "LANGUAGE: " && poetry run python --version

RUN pip install poetry

# Use this page as a reference for python and poetry environment variables:
Expand All @@ -40,61 +49,34 @@ RUN poetry install --no-root --without dev && rm -rf ${POETRY_CACHE_DIR};
FROM build AS test
# Install dev dependencies
RUN poetry install --only dev --no-root && rm -rf ${POETRY_CACHE_DIR};
# Print Python dependencies on the same line with the list starting right after the title
RUN echo "--------DEPENDENCIES---------" && poetry run pip list && echo "--------DEPENDENCIES---------"
COPY . .
# Run tests
USER app
RUN poetry run pytest tests

# Print environment information
RUN echo -n "--------START ENVIRONMENT OUTPUT--------"
RUN echo -n "OS: " && cat /etc/os-release
# Print Debian version on the same line
RUN echo -n "Debian Version: " && cat /etc/debian_version
# Print Python version on the same line
RUN echo -n "LANGUAGE: " && poetry run python --version
# Print Python dependencies on the same line with the list starting right after the title
RUN echo "DEPENDENCIES:" && poetry run pip list
RUN echo -n "--------END ENVIRONMENT OUTPUT--------"

FROM poetry AS build-unlocked-test
COPY pyproject.toml ./
RUN poetry install --no-root && rm -rf ${POETRY_CACHE_DIR};
RUN echo "--------DEPENDENCIES---------" && poetry run pip list && echo "--------DEPENDENCIES---------"
COPY . .
# Run tests
USER app
RUN poetry run pytest tests

# Print environment information
RUN echo -n "--------START ENVIRONMENT OUTPUT--------"
RUN echo -n "OS: " && cat /etc/os-release
# Print Debian version on the same line
RUN echo -n "Debian Version: " && cat /etc/debian_version
# Print Python version on the same line
RUN echo -n "LANGUAGE: " && poetry run python --version
# Print Python dependencies on the same line with the list starting right after the title
RUN echo "DEPENDENCIES:" && poetry run pip list
RUN echo -n "--------END ENVIRONMENT OUTPUT--------"

FROM poetry AS build-latest-test
COPY pyproject.toml ./
RUN sed -i 's/\^/>=/g' pyproject.toml
RUN poetry install --no-root && rm -rf ${POETRY_CACHE_DIR};
RUN echo "--------DEPENDENCIES---------" && poetry run pip list && echo "--------DEPENDENCIES---------"
COPY . .
# Run tests
USER app
RUN poetry run pytest tests

# Print environment information
RUN echo -n "--------START ENVIRONMENT OUTPUT--------"
RUN echo -n "OS: " && cat /etc/os-release
# Print Debian version on the same line
RUN echo -n "Debian Version: " && cat /etc/debian_version
# Print Python version on the same line
RUN echo -n "LANGUAGE: " && poetry run python --version
# Print Python dependencies on the same line with the list starting right after the title
RUN echo "DEPENDENCIES:" && poetry run pip list
RUN echo -n "--------END ENVIRONMENT OUTPUT--------"


FROM base AS production
RUN mkdir -p /venv && chown ${UID}:${GID} /venv
Expand Down

0 comments on commit 5048ffe

Please sign in to comment.