Skip to content

Commit

Permalink
Merge pull request #609 from fragforce/dev
Browse files Browse the repository at this point in the history
Update prod builds
  • Loading branch information
AevumDecessus committed Sep 21, 2023
2 parents 71192cb + 52a36b3 commit 73df78c
Show file tree
Hide file tree
Showing 8 changed files with 546 additions and 612 deletions.
61 changes: 61 additions & 0 deletions .github/workflows/dev-images.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Dev Images

env:
BUILD_ARGS: ""

on:
push:
branches:
- dev

jobs:
build:
name: Build & push docker image
runs-on: ubuntu-latest
env:
IMG_NAME: fragforce-dev
strategy:
max-parallel: 4
matrix:
dockerfile: [ "web", "worker", "beat" ]
steps:
- name: Checkout
uses: actions/checkout@v3
with:
lfs: true
- name: Debug
run: |
echo "github.ref -> {{ github.ref }}"
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
buildkitd-flags: --debug

- name: Docker metadata
id: metadata
uses: docker/metadata-action@v4
with:
images: ghcr.io/${{ github.repository_owner }}/${{ env.IMG_NAME }}-${{ matrix.dockerfile }}
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=ref,event=branch
type=raw,value={{sha}},enable=${{ github.ref_type != 'tag' }}
- name: Login to GitHub Container Registry
if: env.BUILD_ARGS != '--test'
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
file: Dockerfile.${{ matrix.dockerfile }}
push: true
tags: ${{ steps.metadata.outputs.tags }}
labels: ${{ steps.metadata.outputs.labels }}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Builder
name: Prod Images

env:
BUILD_ARGS: ""
Expand All @@ -9,38 +9,40 @@ on:
- v*
branches:
- master
- dev
pull_request:
branches:
- master
- dev

jobs:
build:
name: Build & push docker image
runs-on: ubuntu-latest
env:
IMG_NAME: ${{ github.repository }}
IMG_NAME: fragforce-prod
strategy:
max-parallel: 4
matrix:
dockerfile: [ "web", "worker", "beat" ]
steps:
- name: Checkout
uses: actions/checkout@v3

with:
lfs: true
- name: Debug
run: |
echo "github.ref -> {{ github.ref }}"
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
buildkitd-flags: --debug

- name: Docker metadata
id: metadata
uses: docker/metadata-action@v4
with:
images: ghcr.io/${{ env.IMG_NAME }}
images: ghcr.io/${{ github.repository_owner }}/${{ env.IMG_NAME }}-${{ matrix.dockerfile }}
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=ref,event=branch
type=raw,value={{sha}},enable=${{ github.ref_type != 'tag' }}
- name: Login to GitHub Container Registry
Expand All @@ -56,6 +58,6 @@ jobs:
with:
context: .
file: Dockerfile.${{ matrix.dockerfile }}
push: ${{ github.event.base_ref =='refs/heads/main' && github.ref_type == 'tag' && !startsWith(github.ref, 'refs/tags/v0.')}}
push: true
tags: ${{ steps.metadata.outputs.tags }}
labels: ${{ steps.metadata.outputs.labels }}
17 changes: 12 additions & 5 deletions Dockerfile.beat
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ ENV LANG C.UTF-8
ENV LC_ALL C.UTF-8
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONFAULTHANDLER 1
RUN apt-get update && apt-get install -y --no-install-recommends python3-lxml libpq-dev python3-dev postgresql postgresql-client
RUN apt-get update && apt-get install -y --no-install-recommends python3-lxml python3-dev

FROM base AS python-deps

# Install pipenv and compilation dependencies
RUN pip install --upgrade pip
RUN pip install pipenv asdf
RUN apt-get update && apt-get install -y --no-install-recommends gcc git python-dev postgresql postgresql-client
RUN apt-get install -y --no-install-recommends gcc git

# Install python dependencies in /.venv
COPY Pipfile .
Expand All @@ -29,9 +29,16 @@ ENV PATH="/.venv/bin:$PATH"
# Create and switch to a new user
RUN useradd --create-home appuser
WORKDIR /home/appuser
USER appuser

# Install application into container
COPY . .
COPY extralifeapi extralifeapi
COPY fforg fforg
COPY ffstream ffstream
COPY ffsfdc ffsfdc
COPY ffdonations ffdonations
COPY ffsite ffsite
COPY manage.py .
RUN chown -R appuser /home/appuser
USER appuser

CMD [ "celery", "-A", "fforg", "worker", "-l", "${CELERY_LOG_LEVEL:-INFO}", "--autoscale=1,1", "--beat" ]
CMD [ "celery", "-A", "fforg", "worker", "--autoscale=1,1", "--beat" ]
19 changes: 15 additions & 4 deletions Dockerfile.web
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ ENV LANG C.UTF-8
ENV LC_ALL C.UTF-8
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONFAULTHANDLER 1
RUN apt-get update && apt-get install -y --no-install-recommends python3-lxml libpq-dev python3-dev postgresql postgresql-client
RUN apt-get update && apt-get install -y --no-install-recommends python3-lxml python3-dev

FROM base AS python-deps

# Install pipenv and compilation dependencies
RUN pip install --upgrade pip
RUN pip install pipenv asdf
RUN apt-get update && apt-get install -y --no-install-recommends gcc git python-dev postgresql postgresql-client
RUN apt-get install -y --no-install-recommends gcc git python3-dev

# Install python dependencies in /.venv
COPY Pipfile .
Expand All @@ -29,9 +29,20 @@ ENV PATH="/.venv/bin:$PATH"
# Create and switch to a new user
RUN useradd --create-home appuser
WORKDIR /home/appuser
USER appuser

# Install application into container
COPY . .
COPY extralifeapi extralifeapi
COPY fforg fforg
COPY ffstream ffstream
COPY ffsfdc ffsfdc
COPY ffdonations ffdonations
COPY ffsite ffsite
COPY manage.py .

RUN chown -R appuser /home/appuser
USER appuser

RUN /.venv/bin/python manage.py collectstatic --no-input


CMD [ "gunicorn", "fforg.wsgi" ]
17 changes: 12 additions & 5 deletions Dockerfile.worker
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ ENV LANG C.UTF-8
ENV LC_ALL C.UTF-8
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONFAULTHANDLER 1
RUN apt-get update && apt-get install -y --no-install-recommends python3-lxml libpq-dev python3-dev postgresql postgresql-client
RUN apt-get update && apt-get install -y --no-install-recommends python3-lxml python3-dev

FROM base AS python-deps

# Install pipenv and compilation dependencies
RUN pip install --upgrade pip
RUN pip install pipenv asdf
RUN apt-get update && apt-get install -y --no-install-recommends gcc git python-dev postgresql postgresql-client
RUN apt-get install -y --no-install-recommends gcc git

# Install python dependencies in /.venv
COPY Pipfile .
Expand All @@ -29,9 +29,16 @@ ENV PATH="/.venv/bin:$PATH"
# Create and switch to a new user
RUN useradd --create-home appuser
WORKDIR /home/appuser
USER appuser

# Install application into container
COPY . .
COPY extralifeapi extralifeapi
COPY fforg fforg
COPY ffstream ffstream
COPY ffsfdc ffsfdc
COPY ffdonations ffdonations
COPY ffsite ffsite
COPY manage.py .
RUN chown -R appuser /home/appuser
USER appuser

CMD [ "celery", "-A", "fforg", "worker", "-l", "${CELERY_LOG_LEVEL:-INFO}", "--autoscale=6,2" ]
CMD [ "celery", "-A", "fforg", "worker", "--autoscale=6,2" ]
6 changes: 4 additions & 2 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ python_version = "3.10"
[packages]
ipython = "*"
"psycopg2-binary" = "*"
django-heroku = "*"
gunicorn = "*"
pip = "*"
setuptools = "*"
Expand All @@ -21,14 +20,17 @@ ipy = "*"
"celery[redis]" = "*"
redis = ">=2.10.3"
boto = "*"
"logzio-python-handler" = "*"
celery = ">=5.0.0"
"dj-database-url" = ">=1.3.0"
"django-redis-cache" = ">=2.1"
hiredis = "*"
"django-memoize" = "*"
memoize = "*"
django = ">=4"
protobuf = "*"
requests = "*"
six = "*"
whitenoise = "*"

# Temp until PR finsihed and applied
tiltify2 = {git = "https://github.com/gpmidi/tiltify-v2-api-python.git", ref = "develop-v3", editable = true}
Expand Down
Loading

0 comments on commit 73df78c

Please sign in to comment.