From 1d18d3c05d4c993cbea404df335f7dcc726d6eaf Mon Sep 17 00:00:00 2001 From: varphi-online Date: Sun, 30 Nov 2025 03:10:48 -0700 Subject: [PATCH 1/4] fixes to get static files working as expected, migrations, and remove lfs --- .github/workflows/main.yml | 20 ++++++++++++++------ Forward-server/Dockerfile.Production | 2 +- compose.production.yaml | 5 +++-- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 262cb99..d164337 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -20,9 +20,11 @@ jobs: - name: Checkout Code uses: actions/checkout@v4 with: - # TODO: We should remove this lfs once the first job runs and the DB is seeded with all the video files - lfs: true + lfs: false fetch-depth: 1 + + - name: Remove a directory + run: rm -rf Forward-server/core/management/seed_data Forward-client - name: Deploy to Server uses: easingthemes/ssh-deploy@v5.1.0 @@ -33,10 +35,16 @@ jobs: REMOTE_HOST: ${{ secrets.REMOTE_HOST }} REMOTE_USER: ${{ secrets.REMOTE_USER }} TARGET: ${{ secrets.REMOTE_TARGET }} - # TODO: After first job run, exclude the seed_data folder for bandwidth - EXCLUDE: "/Forward-client, .git/, .github/" + EXCLUDE: "Forward-client, .git/, .github/, Forward-server/core/management/seed_data/" SCRIPT_AFTER: | - cd ${{ secrets.REMOTE_TARGET }} + cd "${{ secrets.REMOTE_TARGET }}" echo "Rebuilding and restarting backend..." - docker-compose -f compose.production.yaml up -d --build backend + docker compose -f compose.production.yaml up -d --build backend + + echo "Running database migrations..." + docker compose -f compose.production.yaml exec -T backend python manage.py migrate + + echo "Collecting static files..." + docker compose -f compose.production.yaml exec -T backend python manage.py collectstatic --noinput + docker image prune -f diff --git a/Forward-server/Dockerfile.Production b/Forward-server/Dockerfile.Production index 8765e69..8d050e6 100644 --- a/Forward-server/Dockerfile.Production +++ b/Forward-server/Dockerfile.Production @@ -15,6 +15,6 @@ COPY . /app EXPOSE 8000 # RUN python manage.py migrate -RUN python manage.py collectstatic --noinput +# RUN python manage.py collectstatic --noinput CMD ["gunicorn", "--config", "gunicorn_config.py", "forward.wsgi:application"] diff --git a/compose.production.yaml b/compose.production.yaml index 9ae46e9..c0273c5 100644 --- a/compose.production.yaml +++ b/compose.production.yaml @@ -6,13 +6,14 @@ services: dockerfile: Dockerfile.Production volumes: - ./Forward-server:/app/server + - static_volume:/app/static restart: unless-stopped + cpus: "0.85" + mem_limit: 750m env_file: - ../env_files/django/.env.production networks: - proxy - volumes: - - static_volume:/app/static caddy: image: caddy From a61675d05969eaf8035686e8cb7be6e5b48c7a9f Mon Sep 17 00:00:00 2001 From: varphi <160203809+varphi-online@users.noreply.github.com> Date: Sun, 30 Nov 2025 03:35:07 -0700 Subject: [PATCH 2/4] Deploy fixes 4 (#179) * fixes to get static files working as expected, migrations, and remove lfs * static files for admin panel --- .github/workflows/main.yml | 2 +- compose.production.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d164337..90e9cfa 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -45,6 +45,6 @@ jobs: docker compose -f compose.production.yaml exec -T backend python manage.py migrate echo "Collecting static files..." - docker compose -f compose.production.yaml exec -T backend python manage.py collectstatic --noinput + docker compose -f compose.production.yaml exec -T backend python manage.py collectstatic --noinput --clear docker image prune -f diff --git a/compose.production.yaml b/compose.production.yaml index c0273c5..dec78e4 100644 --- a/compose.production.yaml +++ b/compose.production.yaml @@ -6,7 +6,7 @@ services: dockerfile: Dockerfile.Production volumes: - ./Forward-server:/app/server - - static_volume:/app/static + - static_volume:/app/staticfiles restart: unless-stopped cpus: "0.85" mem_limit: 750m From a5648f2f8716f45f473c0141ef2c37ee94265cf0 Mon Sep 17 00:00:00 2001 From: varphi-online Date: Sun, 30 Nov 2025 10:28:56 -0700 Subject: [PATCH 3/4] user add in admin panel was not working --- Forward-server/core/admin/core_admin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Forward-server/core/admin/core_admin.py b/Forward-server/core/admin/core_admin.py index 8450dd8..de0a833 100644 --- a/Forward-server/core/admin/core_admin.py +++ b/Forward-server/core/admin/core_admin.py @@ -39,7 +39,7 @@ class CustomUserAdmin(UserAdmin): None, { "classes": ("wide",), - "fields": ("username", "display_name","password", "password2", "facility"), + "fields": ("username", "display_name","password1", "password2", "facility"), }, ), ) From 394e88b2fc30493ad1260074e8571037cc8c5533 Mon Sep 17 00:00:00 2001 From: varphi-online Date: Sun, 30 Nov 2025 11:31:55 -0700 Subject: [PATCH 4/4] fix for announcements title --- Forward-server/core/admin/core_admin.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Forward-server/core/admin/core_admin.py b/Forward-server/core/admin/core_admin.py index de0a833..12e6796 100644 --- a/Forward-server/core/admin/core_admin.py +++ b/Forward-server/core/admin/core_admin.py @@ -233,8 +233,8 @@ def content_view(self, obj): def get_fields(self, request, obj=None): if self.has_change_permission(request, obj): - return ("content",) - return ("content_view",) + return ("title","content",) + return ("title", "content_view",) def get_readonly_fields(self, request, obj=None): if not self.has_change_permission(request, obj):