Skip to content

Instantly share code, notes, and snippets.

@MicrexIT
Created July 14, 2021 11:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MicrexIT/182d1c7446429d9a79ba82afb66f7059 to your computer and use it in GitHub Desktop.
Save MicrexIT/182d1c7446429d9a79ba82afb66f7059 to your computer and use it in GitHub Desktop.
Elixir Phoenix Makefile Deployment
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