-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(poetry): use poetry as the dependency manager (#188)
- Loading branch information
Showing
30 changed files
with
2,190 additions
and
857 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,41 +9,44 @@ on: | |
branches: | ||
- main | ||
- production | ||
paths: | ||
- 'bfportal/**' | ||
|
||
env: | ||
REGISTRY: ghcr.io | ||
IMAGE_NAME: ${{ github.repository }} | ||
|
||
jobs: | ||
# Push image to GitHub Packages. | ||
# See also https://docs.docker.com/docker-hub/builds/ | ||
production-deploy: | ||
runs-on: ubuntu-latest | ||
defaults: | ||
run: | ||
working-directory: ./bfportal | ||
permissions: | ||
contents: read | ||
packages: write | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/checkout@v3 | ||
|
||
- uses: nelonoel/[email protected] | ||
|
||
- name: Build image | ||
run: docker build . --file Dockerfile --tag $BRANCH_NAME | ||
|
||
- name: Log into registry | ||
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin | ||
|
||
- name: Push image | ||
run: | | ||
IMAGE_ID=ghcr.io/${{ github.repository }}/$BRANCH_NAME | ||
# Change all uppercase to lowercase | ||
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]') | ||
# Strip git ref prefix from version | ||
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,') | ||
# Strip "v" prefix from tag name | ||
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//') | ||
# Use Docker `latest` tag convention | ||
VERSION=latest | ||
echo IMAGE_ID=$IMAGE_ID | ||
echo VERSION=$VERSION | ||
docker tag $BRANCH_NAME $IMAGE_ID:$VERSION | ||
docker push $IMAGE_ID:$VERSION | ||
- name: Login to container registry | ||
uses: docker/login-action@v2 | ||
with: | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
registry: ${{ env.REGISTRY }} # ghcr.io | ||
|
||
- name: Extract metadata (tags, labels) for Docker | ||
id: meta | ||
uses: docker/metadata-action@4 | ||
with: | ||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/$BRANCH_NAME | ||
# ghcr.io/battlefield-portal-community/bfportal.gg/production:latest | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
|
||
- name: Build and Push Image | ||
uses: docker/build-push-action@v4 | ||
with: | ||
context: . | ||
push: true | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# Use an official Python runtime based on Debian 10 "buster" as a parent image. | ||
FROM python:3.11-buster as builder | ||
RUN pip install poetry==1.5.1 | ||
ENV POETRY_NO_INTERACTION=1 \ | ||
POETRY_VIRTUALENVS_IN_PROJECT=1 \ | ||
POETRY_VIRTUALENVS_CREATE=1 | ||
|
||
WORKDIR /venv | ||
RUN apt-get update --yes --quiet && apt-get install --yes --quiet --no-install-recommends git | ||
RUN touch README.md | ||
|
||
COPY ["pyproject.toml", "poetry.lock", "./"] | ||
RUN poetry config installer.max-workers 10 | ||
RUN poetry install --without dev --no-root --no-cache | ||
|
||
FROM node:latest as node_base | ||
RUN echo "NODE Version:" && node --version | ||
RUN echo "NPM Version:" && npm --version | ||
|
||
FROM python:3.11-slim-buster as dev | ||
|
||
WORKDIR /app | ||
RUN useradd --create-home wagtail | ||
|
||
# Port used by this container to serve HTTP. | ||
EXPOSE 8000 | ||
# Install system packages required by Wagtail and Django. | ||
RUN apt-get update --yes --quiet && apt-get install --yes --quiet --no-install-recommends \ | ||
build-essential \ | ||
libpq-dev \ | ||
libmariadbclient-dev \ | ||
libjpeg62-turbo-dev \ | ||
zlib1g-dev \ | ||
libwebp-dev \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
# Set environment variables. | ||
# 1. Force Python stdout and stderr streams to be unbuffered. | ||
# 2. Set PORT variable that is used by Gunicorn. This should match "EXPOSE" | ||
# command. | ||
ENV PYTHONUNBUFFERED=1 \ | ||
PORT=8000 \ | ||
PYTHONDONTWRITEBYTECODE=1 \ | ||
USER="wagtail" \ | ||
VIRTUAL_ENV=/venv/.venv | ||
|
||
ENV PATH="${VIRTUAL_ENV}/bin:${PATH}:/home/wagtail/.local/bin" | ||
COPY --from=builder ${VIRTUAL_ENV} ${VIRTUAL_ENV} | ||
|
||
# Copy the source code of the project into the container. | ||
COPY ./bfportal ./ | ||
|
||
FROM dev as final | ||
COPY --chown=wagtail:wagtail --from=node_base /usr/local/bin /usr/local/bin | ||
COPY --chown=wagtail:wagtail --from=node_base /usr/local/lib/node_modules/npm /usr/local/lib/node_modules/npm | ||
|
||
ENV NPM_BIN_PATH = "/usr/local/bin/npm" | ||
RUN python manage.py tailwind install --no-input; | ||
RUN python manage.py tailwind build --no-input | ||
RUN python manage.py collectstatic --noinput --clear |
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.