Open bjarneo opened 1 week ago
Snippet from our makefile (deploys a Symfony application):
SSH_TESTING := some_remote_host
SSH_PRODUCTION := some_remote_host
PHONY += --deploy
--deploy: export COMPOSE_FILE := compose.live.yaml
--deploy: export DOCKER_HOST := ssh://$(SSH)
--deploy:
$(eval BUILD := $(shell ssh $(SSH) "docker inspect -f '{{ index .Config.Labels \"gha.build\" }}' $(PROJECT)-$(INSTANCE)"))
BUILD=$(BUILD) op run --env-file="./.env.$(INSTANCE)" -- docker compose config
BUILD=$(BUILD) op run --env-file="./.env.$(INSTANCE)" -- docker compose up --wait --remove-orphans
BUILD=$(BUILD) op run --env-file="./.env.$(INSTANCE)" -- docker compose exec app bin/console --ansi cache:clear
BUILD=$(BUILD) op run --env-file="./.env.$(INSTANCE)" -- docker compose exec app bin/console --ansi about
PHONY += deploy-testing
deploy-testing: INSTANCE := test
deploy-testing: SSH := $(SSH_TESTING)
deploy-testing: --deploy ## Deploy to Testing
PHONY += deploy-production
deploy-production: INSTANCE := prod
deploy-production: SSH := $(SSH_PRODUCTION)
deploy-production: --deploy ## Deploy to Production
So here you can run this like:
Deploy a certain (new) build (we use it within docker image tag):
make deploy-testing BUILD=123
Or re-reploy current build (it gets currently running build number from running container):
make deploy-testing
Thank you, great information to add!
Move from plain docker to use docker compose. Easier to handle config & replicas.