diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 2e96d1ca..4446fa95 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -1,19 +1,16 @@ name: deploy -on: - workflow_dispatch: +on: workflow_dispatch jobs: deploy: - name: "Deploy" runs-on: ubuntu-latest steps: - - name: Temporarily save SSH key to file - run: | - echo "${{ secrets.SSH_DEPLOY_KEY }}" > deploy_key - chmod 600 deploy_key - - name: Run deployment via SSH - run: ssh -o "StrictHostKeyChecking=no" -i deploy_key webstrom@server.strom.sk deploy-backend - - - name: Clean SSH key - run: rm -f deploy_key + - uses: actions/checkout@v3 + - uses: wshihadeh/docker-deployment-action@v2 + with: + remote_docker_host: webstrom@server.strom.sk + ssh_private_key: ${{ secrets.WEBSTROM_DEPLOY_SSH_PRIVATE_KEY }} + ssh_public_key: ${{ secrets.WEBSTROM_DEPLOY_SSH_PUBLIC_KEY }} + stack_file_name: compose.yaml + args: up --build --force-recreate --detach diff --git a/Dockerfile b/Dockerfile index 9bdbe650..bbe44070 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,15 +1,17 @@ FROM python:3.11 -EXPOSE 8000 - WORKDIR /app COPY Pipfile /app COPY Pipfile.lock /app -RUN ["pip", "install", "pipenv"] -RUN ["pipenv", "install", "--dev", "--deploy", "--system"] +RUN pip install pipenv +RUN pipenv sync --dev --system COPY . /app -CMD ["/app/docker_entrypoint.sh"] +RUN python manage.py restoredb + +EXPOSE 8000 + +ENTRYPOINT [ "daphne", "-b", "0.0.0.0", "-p", "8000", "webstrom.asgi:application" ] diff --git a/compose.yaml b/compose.yaml index aebee6a8..6aed2794 100644 --- a/compose.yaml +++ b/compose.yaml @@ -3,6 +3,7 @@ version: "3.3" services: website: build: . + image: webstrom-backend ports: - "8000:8000" restart: always diff --git a/docker_entrypoint.sh b/docker_entrypoint.sh deleted file mode 100755 index 9eec485c..00000000 --- a/docker_entrypoint.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash - -python manage.py restoredb - -daphne -b 0.0.0.0 -p 8000 webstrom.asgi:application