diff options
author | Matthew Lemon <y@yulqen.org> | 2025-01-06 14:24:55 +0000 |
---|---|---|
committer | Matthew Lemon <y@yulqen.org> | 2025-01-06 14:24:55 +0000 |
commit | 639eff8baa39429efc3461fea56c047de9c4c789 (patch) | |
tree | c70321625fa322b6845bc35e4d74ebbe6447ba29 /Makefile | |
parent | 0e88da8dc7bd509f561ddec5614b6cfc2cd509d0 (diff) |
Update Makefile with rule to deploy to staging
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 54 |
1 files changed, 22 insertions, 32 deletions
@@ -1,35 +1,25 @@ -all: build run migrate collectstatic - -start: build run migrate collectstatic - -sass: - sass --no-source-map ~/code/python/alphabetlearning/alphabetlearning/static/scss/custom.scss ~/code/python/alphabetlearning/alphabetlearning/static/css/custom.css - -sync-env: - scp .env-prod substracker-web:code/alphabetlearning/.env - -build: - @docker build -f compose/production/django/Dockerfile -t alphabetlearning:latest . - -push: - @docker build -f compose/production/django/Dockerfile -t alphabetlearning:latest . && docker tag alphabetlearning registry.digitalocean.com/twentyfour-registry/pyblackbird && docker push registry.digitalocean.com/twentyfour-registry/pyblackbird - -clean-registry: - @doctl registry garbage-collection start --include-untagged-manifests twentyfour-registry - -run: - @docker run -d --rm --name alphabetlearning_django --env-file .env -p 8080:8080 alphabetlearning - -collectstatic: - @docker run --rm --env-file .env -v .:/app pyblackbird sh -c "python manage.py collectstatic --noinput" - -migrate: - @docker run --rm --env-file .env -v .:/app pyblackbird sh -c "python manage.py makemigrations && python manage.py migrate" - -clean: - @docker stop pyblackbird - @sleep 2 - @docker rmi pyblackbird +deploy-to-staging: +# Define variables +SERVER_USER = jo +SERVER_IP = jo.banded-neon.ts.net +PROJECT_DIR = /home/jo/alphabetlearning + +.PHONY: deploy + +deploy-to-staging: + @echo "1. Pushing changes to remote repository..." + git push + @echo "2. Logging into the server and pulling latest changes..." + ssh $(SERVER_USER)@$(SERVER_IP) "cd $(PROJECT_DIR) && git pull" + @echo "3. Building the Docker image..." + ssh $(SERVER_USER)@$(SERVER_IP) "cd $(PROJECT_DIR) && docker compose build --no-cache" + @echo "4. Running the Docker container..." + ssh $(SERVER_USER)@$(SERVER_IP) "cd $(PROJECT_DIR) && docker compose up -d" + @echo "5. Migrating database..." + ssh $(SERVER_USER)@$(SERVER_IP) "cd $(PROJECT_DIR) && docker compose exec web uv run manage.py migrate" + @echo "6. Collecing static files..." + ssh $(SERVER_USER)@$(SERVER_IP) "cd $(PROJECT_DIR) && docker compose exec web uv run manage.py collectstatic --noinput" + @echo "Deployment completed!" test-all: @pytest -q -s . |