Created
July 14, 2021 11:43
-
-
Save MicrexIT/182d1c7446429d9a79ba82afb66f7059 to your computer and use it in GitHub Desktop.
Elixir Phoenix Makefile Deployment
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ifneq (,$(wildcard ./.env)) | |
include .env | |
export | |
endif | |
build: | |
ifdef VERSION | |
docker build --rm \ | |
--build-arg DATABASE_URL=$(DATABASE_URL) \ | |
--build-arg SECRET_KEY_BASE=$(SECRET_KEY_BASE) \ | |
--build-arg MIX_ENV=$(MIX_ENV) \ | |
-t $(IMAGE_NAME):$(VERSION) . && \ | |
docker tag $(IMAGE_NAME):$(VERSION) $(IMAGE_NAME):latest | |
else | |
echo "VERSION not defined" | |
endif | |
start: | |
ifdef DATABASE_URL | |
ifdef SECRET_KEY_BASE | |
docker run -d \ | |
--network $(NETWORK) \ | |
-p $(APP_PORT):$(APP_PORT) \ | |
-e DATABASE_URL=$(DATABASE_URL) \ | |
-e SECRET_KEY_BASE=$(SECRET_KEY_BASE) \ | |
-e MIX_ENV=$(MIX_ENV) \ | |
--name $(CONTAINER_NAME) $(IMAGE_NAME) | |
else | |
echo "SECRET_KEY_BASE not defined" | |
endif | |
else | |
echo "DATABASE_URL not defined" | |
endif | |
restart: | |
ifdef DATABASE_URL | |
ifdef SECRET_KEY_BASE | |
docker stop the-oz_${APP_NAME} && \ | |
docker rm the-oz_${APP_NAME} && \ | |
docker run -d \ | |
--network $(NETWORK) \ | |
-p $(APP_PORT):$(APP_PORT) \ | |
-e DATABASE_URL=$(DATABASE_URL) \ | |
-e SECRET_KEY_BASE=$(SECRET_KEY_BASE) \ | |
-e MIX_ENV=$(MIX_ENV) \ | |
--name $(CONTAINER_NAME) $(IMAGE_NAME) | |
else | |
echo "SECRET_KEY_BASE not defined" | |
endif | |
else | |
echo "DATABASE_URL not defined" | |
endif | |
shell: | |
docker container run --rm -it \ | |
--network $(NETWORK) \ | |
--entrypoint "" \ | |
-p $(APP_PORT):$(APP_PORT) \ | |
-e DATABASE_URL=$(DATABASE_URL) \ | |
-e SECRET_KEY_BASE=$(SECRET_KEY_BASE) \ | |
-e MIX_ENV=$(MIX_ENV) \ | |
$(IMAGE_NAME) sh | |
exec: | |
docker container exec -it \ | |
$(CONTAINER_NAME) sh | |
logs: | |
docker container logs --follow --tail 100 \ | |
$(CONTAINER_NAME) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment