diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 262cb99..90e9cfa 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 --clear + 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/Forward-server/core/admin/core_admin.py b/Forward-server/core/admin/core_admin.py index 8450dd8..12e6796 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"), }, ), ) @@ -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): diff --git a/compose.production.yaml b/compose.production.yaml index 9ae46e9..dec78e4 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/staticfiles 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