diff --git a/.dockerignore b/.dockerignore index c03e13b..177581c 100644 --- a/.dockerignore +++ b/.dockerignore @@ -2,4 +2,5 @@ firefox/ chrome/ dumps/ media/ -TODO.md \ No newline at end of file +TODO.md +.env \ No newline at end of file diff --git a/.env.sample b/.env.sample index d690a20..8102e17 100644 --- a/.env.sample +++ b/.env.sample @@ -46,8 +46,10 @@ STRIPE_SECRET_WEBHOOK = '' USE_VAULT = 'False' SERVE_MEDIA = 'False' -BACKEND_URL = 'localhost:8000' -FRONTEND_URL = 'localhost:4200' +BACKEND_ADDRESS = 'localhost' +BACKEND_PORT = 8000 +FRONTEND_ADDRESS = 'localhost' +FRONTEND_PORT = 4200 USE_HTTPS = 'False' TIMEZONE = 'Asia/Manila' diff --git a/.woodpecker.yml b/.woodpecker.yml new file mode 100644 index 0000000..cbb9454 --- /dev/null +++ b/.woodpecker.yml @@ -0,0 +1,30 @@ +# .woodpecker.yml +steps: + - name: build & push + image: alpine:3.20.2 + when: + - branch: master + - event: push + commands: + - apt update && apt install -y docker docker-buildx-plugin + - docker buildx build . -t git.keannu1.duckdns.org/keannu125/drf_template + - cat "$GITEA_PASSWORD" | docker login git.keannu1.duckdns.org --username "$GITEA_USERNAME" --pasword-stdin + - docker push git.keannu1.duckdns.org/keannu125/drf_template + - name: update deployment and reset database + image: alpine:3.20.2 + when: + - branch: master + - event: push + commands: + - mkdir -p /root/.ssh/ + - echo "$SSH_KEY" | tr -d '\r' > /root/.ssh/id_rsa + - chmod 600 /root/.ssh/id_rsa + - echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > /root/.ssh/config + - ssh root@10.0.10.4 ' + cd /mnt/nvme/files/docker projects/EquipmentTracker-Backend; + docker-compose down; + docker image rm git.keannu1.duckdns.org/keannu125/drf_template; + docker volume rm git.keannu1.duckdns.org/keannu125/drf_template_db_data; + docker compose up -d' + - scp -r dist/* root@10.0.10.4:/mnt/nvme/www/equipment_tracker_frontend + secrets: [SSH_KEY, REGISTRY_USERNAME, REGISTRY_PASSWORD] diff --git a/backend/config/settings.py b/backend/config/settings.py index ef6f053..155d431 100644 --- a/backend/config/settings.py +++ b/backend/config/settings.py @@ -37,8 +37,10 @@ def get_secret(secret_name): # URL Prefixes USE_HTTPS = (get_secret('USE_HTTPS') == 'True') URL_PREFIX = 'https://' if USE_HTTPS else 'http://' -BACKEND_URL = URL_PREFIX + get_secret('BACKEND_URL') -FRONTEND_URL = URL_PREFIX + get_secret('FRONTEND_URL') +BACKEND_URL = URL_PREFIX + \ + get_secret('BACKEND_ADDRESS') + ':' + get_secret('BACKEND_PORT') +FRONTEND_URL = URL_PREFIX + \ + get_secret('FRONTEND_ADDRESS') + ':' + get_secret('FRONTEND_PORT') ALLOWED_HOSTS = ['*'] CSRF_TRUSTED_ORIGINS = [ diff --git a/docker-compose.yml b/docker-compose.yml index 419abf9..8dcbebe 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -10,7 +10,7 @@ services: dockerfile: Dockerfile image: drf_template:latest ports: - - "8000:8000" + - "${BACKEND_PORT}:${BACKEND_PORT}" environment: - PYTHONBUFFERED=1 - RUN_TYPE=web