-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* try: makefile * fix: docker compose * feat: generate PATH_ENV only if != None * Makefile launch-amp-data * fix: BLOOM_DEV_DOCKER use ${POSTGRES_PORT} + clean * merged * update config.__dict__ * fix: scripts/update_env.sh add exec mod * fix: remove .env loading in entreypoint.sh. No need as --env-file is now used * fix: back to app port instead of POSTGRES_PORT * fix: docker compose instead of docker-compose (plugin instead of command) * fix: correct name of generate env /tmp/.docker.${APP_ENV} * feat add EXPOSED_POSTGRES_PORT * fix: Makefile ++ * fix: Makefile production add --host POSTGRES_HOSTNAME * fix: Makefile working + add POSTGRES_IP for production server --------- Co-authored-by: RV <RV>
- Loading branch information
Showing
9 changed files
with
108 additions
and
74 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
EXPOSED_POSTGRES_PORT=25432 | ||
POSTGRES_USER=bloomdev |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
POSTGRES_USER=bloom-prod |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
POSTGRES_PORT=15432 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,74 @@ | ||
VERSION ?= 1.0.0 | ||
|
||
BLOOM_DEV_DOCKER = @docker run --name bloom-test --mount type=bind,source="$(shell pwd)",target=/source_code --env-file ./.env.test --network=bloom_net -p 8501:8501 | ||
BLOOM_PRODUCTION_DOCKER = @docker run --mount type=bind,source="$(shell pwd)",target=/source_code --env-file ./.env --log-driver json-file --log-opt max-size=10M --log-opt max-file=3 --entrypoint /entrypoint.sh | ||
BLOOM_DEV_DOCKER = docker run --name bloom-dev --mount type=bind,source="$(shell pwd)",target=/source_code --env-file /tmp/.env.docker.dev --network=bloom_net -e POSTGRES_PORT=5432 -p 8501:8501 | ||
BLOOM_PRODUCTION_DOCKER = docker run --add-host ${POSTGRES_HOSTNAME}:$${POSTGRES_IP} --mount type=bind,source="$(shell pwd)",target=/source_code --env-file /tmp/.env.docker.prod --log-driver json-file --log-opt max-size=10M --log-opt max-file=3 --entrypoint /entrypoint.sh | ||
|
||
UPDATE_SETTINGS = @python -c "from bloom.config import settings" | ||
EXPORT_ENV_DEV = @export $(shell cat /tmp/.env.docker.dev | grep -v "#" | xargs -d '\r') | ||
EXPORT_ENV_TEST = @export $(shell cat /tmp/.env.docker.test | grep -v "#" | xargs -d '\r') | ||
EXPORT_ENV_PROD = @export $(shell cat /tmp/.env.docker.prod | grep -v "#" | xargs -d '\r') | ||
|
||
UPDATE_ENV_DEV = @$(shell pwd)/scripts/update_env.sh dev /tmp/.env.docker.dev | ||
UPDATE_ENV_TEST = @$(shell pwd)/scripts/update_env.sh test /tmp/.env.docker.test | ||
UPDATE_ENV_PROD = @$(shell pwd)/scripts/update_env.sh prod /tmp/.env.docker.prod | ||
|
||
# Regenerate .env file according to .env.template, .env.local, APP_ENV value, .env.${APP_ENV}, .env.${APP_ENV}.local | ||
update_env: | ||
$(UPDATE_SETTINGS) | ||
|
||
build: | ||
@docker build -t d4g/bloom:${VERSION} --platform linux/amd64 -f docker-env/Dockerfile . | ||
@docker tag d4g/bloom:${VERSION} d4g/bloom:latest | ||
|
||
test-config: | ||
$(UPDATE_ENV_DEV) | ||
$(EXPORT_ENV_DEV) && env | ||
|
||
launch-dev-db: | ||
@docker compose -f docker-env/docker-compose-db.yaml up -d | ||
$(UPDATE_ENV_DEV) | ||
$(EXPORT_ENV_DEV) && docker compose -f docker-env/docker-compose-db.yaml up -d | ||
@sleep 20 | ||
$(BLOOM_DEV_DOCKER) --rm d4g/bloom:${VERSION} alembic upgrade head | ||
$(BLOOM_DEV_DOCKER) --rm d4g/bloom:${VERSION} /venv/bin/python3 alembic/init_script/load_vessels_data.py | ||
$(EXPORT_ENV_DEV) && $(BLOOM_DEV_DOCKER) --rm d4g/bloom:${VERSION} alembic upgrade head | ||
$(EXPORT_ENV_DEV) && $(BLOOM_DEV_DOCKER) --rm d4g/bloom:${VERSION} /venv/bin/python3 alembic/init_script/load_vessels_data.py | ||
|
||
load-amp-data: | ||
$(BLOOM_DEV_DOCKER) --rm d4g/bloom:${VERSION} /venv/bin/python3 alembic/init_script/load_amp_data.py | ||
$(UPDATE_ENV_DEV) | ||
$(EXPORT_ENV_DEV) && $(BLOOM_DEV_DOCKER) --rm d4g/bloom:${VERSION} /venv/bin/python3 alembic/init_script/load_amp_data.py | ||
|
||
load-test-positions-data: | ||
$(BLOOM_DEV_DOCKER) --rm d4g/bloom:${VERSION} /venv/bin/python3 alembic/init_script/load_positions_data.py | ||
$(UPDATE_ENV_DEV) | ||
$(EXPORT_ENV_DEV) && $(BLOOM_DEV_DOCKER) --rm d4g/bloom:${VERSION} /venv/bin/python3 alembic/init_script/load_positions_data.py | ||
|
||
launch-dev-container: | ||
$(BLOOM_DEV_DOCKER) -dti d4g/bloom:${VERSION} /bin/bash | ||
$(UPDATE_ENV_DEV) | ||
$(EXPORT_ENV_DEV) && $(BLOOM_DEV_DOCKER) -dti d4g/bloom:${VERSION} /bin/bash | ||
|
||
launch-dev-app: | ||
$(BLOOM_DEV_DOCKER) --rm d4g/bloom:${VERSION} /venv/bin/python3 app.py | ||
$(UPDATE_ENV_DEV) | ||
$(EXPORT_ENV_DEV) && $(BLOOM_DEV_DOCKER) --rm d4g/bloom:${VERSION} /venv/bin/python3 app.py | ||
|
||
launch-test: | ||
$(BLOOM_DEV_DOCKER) --rm d4g/bloom:${VERSION} tox -vv | ||
$(UPDATE_ENV_DEV) | ||
$(EXPORT_DEV_DEV) && $(BLOOM_DEV_DOCKER) --rm d4g/bloom:${VERSION} tox -vv | ||
|
||
rm-dev-db: | ||
@docker-compose -f docker-env/docker-compose-db.yaml stop | ||
@docker-compose -f docker-env/docker-compose-db.yaml rm | ||
@docker compose -f docker-env/docker-compose-db.yaml stop | ||
@docker compose -f docker-env/docker-compose-db.yaml rm | ||
|
||
rm-dev-env: | ||
@docker stop bloom-test | ||
@docker rm bloom-test | ||
|
||
init-production: | ||
$(BLOOM_PRODUCTION_DOCKER) --name bloom-production-db-init --rm d4g/bloom:${VERSION} alembic upgrade head | ||
$(BLOOM_PRODUCTION_DOCKER) --name bloom-production-db-init --rm d4g/bloom:${VERSION} /venv/bin/python3 alembic/init_script/load_vessels_data.py | ||
$(UPDATE_ENV_PROD) | ||
$(EXPORT_ENV_PROD) && $(BLOOM_PRODUCTION_DOCKER) --name bloom-production-db-init --rm d4g/bloom:${VERSION} alembic upgrade head | ||
$(EXPORT_ENV_PROD) && $(BLOOM_PRODUCTION_DOCKER) --name bloom-production-db-init --rm d4g/bloom:${VERSION} /venv/bin/python3 alembic/init_script/load_vessels_data.py | ||
|
||
launch-production: | ||
$(BLOOM_PRODUCTION_DOCKER) --name bloom-production -d d4g/bloom:${VERSION} cron -f -L 2 | ||
$(UPDATE_ENV_PROD) | ||
$(EXPORT_ENV_PROD) && $(BLOOM_PRODUCTION_DOCKER) --name bloom-production -d d4g/bloom:${VERSION} cron -f -L 2 | ||
|
||
launch-production-app: | ||
$(BLOOM_PRODUCTION_DOCKER) --name bloom-production-app --rm d4g/bloom:${VERSION} /venv/bin/python3 app.py | ||
$(UPDATE_ENV_PROD) | ||
$(EXPORT_ENV_PROD) && $(BLOOM_PRODUCTION_DOCKER) --name bloom-production-app --rm d4g/bloom:${VERSION} /venv/bin/python3 app.py | ||
|
||
dump-dev-db: | ||
$(BLOOM_DEV_DOCKER) --rm postgres:latest sh -c 'export PGPASSWORD=$$POSTGRES_PASSWORD && pg_dump -Fc $$POSTGRES_DB -h $$POSTGRES_HOSTNAME -p $$POSTGRES_PORT -U $$POSTGRES_USER> /source_code/bloom_$(shell date +%Y%m%d_%H%M).dump' | ||
|
||
dump-db: | ||
@docker run --mount type=bind,source="$(shell pwd)",target=/source_code --env-file ./.env.test --network=bloom_net --rm postgres:latest sh -c 'export PGPASSWORD=$$POSTGRES_PASSWORD && pg_dump -Fc $$POSTGRES_DB -h $$POSTGRES_HOSTNAME -p $$POSTGRES_PORT -U $$POSTGRES_USER> /source_code/bloom_$(shell date +%Y%m%d_%H%M).dump' | ||
@docker run --mount type=bind,source="$(shell pwd)",target=/source_code --env-file ./.env.test --network=bloom_net --rm postgres:latest sh -c 'export PGPASSWORD=$$POSTGRES_PASSWORD && pg_dump -Fc $$POSTGRES_DB -h $$POSTGRES_HOSTNAME -p $$POSTGRES_PORT -U $$POSTGRES_USER> /source_code/bloom_$(shell date +%Y%m%d_%H%M).dump' |
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/bin/bash | ||
export APP_ENV=$1 | ||
export PATH_ENV=$2 | ||
/venv/bin/python3 -c "from bloom.config import settings" | ||
export $(cat $2 | grep -v "#" | xargs -d '\r'); |