-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
642 additions
and
180 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,42 @@ | ||
name: Build and Deploy to GKE (Google Kubernetes Engine) | ||
# This workflow will build a docker container and publish it to Google Container Registry | ||
|
||
name: Production build and publish | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
|
||
env: | ||
REGISTRY_HOSTNAME: eu.gcr.io | ||
GKE_PROJECT: ${{ secrets.GKE_PROJECT }} | ||
GKE_EMAIL: ${{ secrets.GKE_EMAIL }} | ||
GITHUB_SHA: ${{ github.sha }} | ||
IMAGE: maguire-backend | ||
REGISTRY_HOSTNAME: eu.gcr.io | ||
DEPLOYMENT_NAME: gke-test | ||
|
||
jobs: | ||
setup-build-publish: | ||
name: Setup, Build, Publish | ||
backend: | ||
name: build and publish backend | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
# Setup gcloud CLI | ||
- uses: google-github-actions/setup-gcloud@v0 | ||
with: | ||
version: '270.0.0' | ||
service_account_email: ${{ secrets.GKE_EMAIL }} | ||
service_account_key: ${{ secrets.GKE_KEY }} | ||
|
||
# Configure docker to use the gcloud command-line tool as a credential helper | ||
- run: | | ||
# Set up docker to authenticate | ||
# via gcloud command-line tool. | ||
gcloud auth configure-docker | ||
# Build the Docker image | ||
- name: Build Maguire Backend | ||
run: | | ||
docker build -t "$REGISTRY_HOSTNAME"/"$GKE_PROJECT"/"$IMAGE":"$GITHUB_SHA" \ | ||
--build-arg GITHUB_SHA="$GITHUB_SHA" \ | ||
--build-arg GITHUB_REF="$GITHUB_REF" backend | ||
# Push the Docker image to Google Container Registry | ||
- name: Publish Maguire Backend | ||
run: | | ||
docker push $REGISTRY_HOSTNAME/$GKE_PROJECT/$IMAGE:$GITHUB_SHA | ||
- name: Check out repository | ||
uses: actions/checkout@v4 | ||
|
||
- id: auth | ||
uses: google-github-actions/auth@v2 | ||
with: | ||
credentials_json: ${{ secrets.GKE_KEY }} | ||
|
||
- name: Set up Cloud SDK | ||
uses: google-github-actions/setup-gcloud@v2 | ||
|
||
- name: Setup docker gcloud auth | ||
run: | | ||
# configure docker to authenticate via gcloud command-line tool | ||
gcloud auth configure-docker | ||
- name: Build backend docker image | ||
run: | | ||
docker build -t "$REGISTRY_HOSTNAME"/"$GKE_PROJECT"/maguire-backend:"$GITHUB_SHA" backend | ||
- name: Publish backend docker image | ||
run: | | ||
docker push $REGISTRY_HOSTNAME/$GKE_PROJECT/maguire-backend:$GITHUB_SHA |
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 |
---|---|---|
@@ -1,11 +1,12 @@ | ||
FROM praekeltfoundation/django-bootstrap:py3.8-buster | ||
FROM ghcr.io/praekeltfoundation/docker-django-bootstrap-nw:py3.10-bullseye | ||
|
||
COPY . /app | ||
RUN pip install -r requirements.txt | ||
RUN pip install -e . | ||
|
||
ENV SENTRY_RELEASE=${VCS_HASH} | ||
ENV DJANGO_SETTINGS_MODULE maguire.settings | ||
ENV CELERY_APP maguire | ||
|
||
RUN django-admin collectstatic --noinput | ||
CMD ["maguire.wsgi:application", "--threads", "5", "--timeout", "300"] | ||
CMD ["maguire.wsgi:application", "--workers", "2", "--threads", "3", "--timeout", "420", "--max-requests", "1000", "--max-requests-jitter", "100", "--graceful-timeout", "300"] |
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
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
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
Oops, something went wrong.