Skip to content

Commit

Permalink
Merge pull request #231 from matematikk-mooc/aj/DIT-226
Browse files Browse the repository at this point in the history
DIT-223: Fix for cache permissions issues and updated branch name to stage
  • Loading branch information
ajxudir authored Aug 28, 2024
2 parents daa763b + 41aa88b commit 12e16e9
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 9 deletions.
2 changes: 2 additions & 0 deletions .docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ RUN apt-get update && apt-get install -y \
apt-get clean && rm -rf /var/lib/apt/lists/*

RUN mkdir /app
RUN mkdir -p /app/.cache && chmod -R 777 /app/.cache

##############################################################
# Startup
Expand All @@ -28,6 +29,7 @@ WORKDIR /app
USER root
ENV PYTHONUNBUFFERED=1
ENV PYTHONDONTWRITEBYTECODE=1
ENV PIP_CACHE_DIR=/app/.cache

EXPOSE 8000
ENTRYPOINT ["/app/.docker/startup.sh"]
12 changes: 8 additions & 4 deletions .docker/startup.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

echo -e "\n\n\n[1/3] Copy and import .env variables to the current shell"
echo -e "\n\n\n[1/4] Copy and import .env variables to the current shell"
echo -e "##############################################################\n"
ENV_FILE=".env"
if [ ! -f "$ENV_FILE" ]; then
Expand All @@ -23,10 +23,14 @@ while IFS='=' read -r key value; do
done < "$ENV_FILE"
set +o allexport

echo -e "\n\n\n[2/3] Install PIP packages"
echo -e "\n\n\n[2/4] Install PIP packages"
echo -e "##############################################################\n"
pip3 install -r requirements.txt
pip3 --cache-dir=/app/.cache install -r requirements.txt

echo -e "\n\n\n[3/3] Start Django server"
echo -e "\n\n\n[3/4] Apply Django migrations"
echo -e "##############################################################\n"
python manage.py migrate

echo -e "\n\n\n[4/4] Start Django server"
echo -e "##############################################################\n"
python manage.py runserver 0.0.0.0:8000
2 changes: 1 addition & 1 deletion .github/workflows/health-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:

- name: Check if data from API is less than DATA_MAX_AGE seconds old
run: |
if [ "$GITHUB_REF" = "refs/heads/staging" ]
if [ "$GITHUB_REF" = "refs/heads/stage" ]
then
chmod 700 $GITHUB_WORKSPACE/.github/health_test_src/do_health_test.py
API_BASE_URL=$STAGING_API_BASE_URL $GITHUB_WORKSPACE/.github/health_test_src/do_health_test.py
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
workflow_dispatch:
push:
branches:
- staging
- stage
- master
- test
paths-ignore:
Expand Down Expand Up @@ -88,7 +88,7 @@ jobs:
- name: Build and push Docker image to registry, triggering new deployment
run: |
if [ "$GITHUB_REF" = "refs/heads/staging" ]
if [ "$GITHUB_REF" = "refs/heads/stage" ]
then
docker build --build-arg WEBSITES_PORT=$WEBSITES_PORT . -f Dockerfile -t $AZURE_CONTAINER_REGISTRY/statistics-api-staging:$GITHUB_SHA -t $AZURE_CONTAINER_REGISTRY/statistics-api-staging:latest
az webapp config appsettings set --subscription ${{ secrets.AZURE_SUBSCRIPTION_ID }} -g $AZURE_RESOURCE_GROUP -n $AZURE_APP_NAME --slot staging --settings "GIT_COMMIT=${GITHUB_SHA}"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ Alternatively, you can directly utilize the stage database by updating all varia

## Deployment (WIP)

Any merge to `staging` or `master` branch will automatically deploy the application to the staging and production environments respectively.
Any merge to `stage` or `master` branch will automatically deploy the application to the stage and production environments respectively.

### GitHub Actions

Expand Down
1 change: 0 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ services:
CANVAS_ACCESS_KEY: "" # Generate a new access key here: https://bibsys.test.instructure.com/profile/settings
volumes:
- ./:/app
- kpas_stats_pip_data:/root/.cache/pip
ports:
- "8000:8000"
networks:
Expand Down

0 comments on commit 12e16e9

Please sign in to comment.