From f8d341f94a05b877124422a7c2fd6d24a790faca Mon Sep 17 00:00:00 2001 From: Jack Laxson Date: Mon, 17 Jun 2019 16:55:39 -0400 Subject: [PATCH] wizard fixup (#55) * Retool dockerfile to stick to 3.7 & add maintainer, change wizard to not default always to "app", run when .env exists (like it does in the git tree) * don't mix up microblog.pub v. micropub --- Makefile | 4 ++-- setup_wizard/Dockerfile | 4 +++- setup_wizard/wizard.py | 9 +++++---- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 656a651..0f56b7a 100644 --- a/Makefile +++ b/Makefile @@ -2,13 +2,13 @@ PYTHON=python SETUP_WIZARD_IMAGE=microblogpub-setup-wizard:latest PWD=$(shell pwd) -# Build the config (will error if an existing config is found) via a Docker container +# Build the config (will error if an existing config/me.yml is found) via a Docker container .PHONY: config config: # Build the container for the setup wizard on-the-fly cd setup_wizard && docker build . -t $(SETUP_WIZARD_IMAGE) # Run and remove instantly - -docker run --rm -it --volume $(PWD):/app/out $(SETUP_WIZARD_IMAGE) + -docker run -e MICROBLOGPUB_WIZARD_PROJECT_NAME --rm -it --volume $(PWD):/app/out $(SETUP_WIZARD_IMAGE) # Finally, remove the tagged image docker rmi $(SETUP_WIZARD_IMAGE) diff --git a/setup_wizard/Dockerfile b/setup_wizard/Dockerfile index 4890f07..83b54b3 100644 --- a/setup_wizard/Dockerfile +++ b/setup_wizard/Dockerfile @@ -1,5 +1,7 @@ -FROM python:3 +FROM python:3.7 WORKDIR /app ADD . /app RUN pip install -r requirements.txt +LABEL maintainer="t@a4.io" +LABEL pub.microblog.oneshot=true CMD ["python", "wizard.py"] diff --git a/setup_wizard/wizard.py b/setup_wizard/wizard.py index dfc7199..98b9676 100644 --- a/setup_wizard/wizard.py +++ b/setup_wizard/wizard.py @@ -15,12 +15,11 @@ def main() -> None: config_file = Path("/app/out/config/me.yml") env_file = Path("/app/out/.env") - if config_file.exists() or env_file.exists(): + if config_file.exists(): # Spit out the relative path for the "config artifacts" rconfig_file = "config/me.yml" - renv_file = ".env" print( - f"Existing setup detected, please delete {rconfig_file} and/or {renv_file} before restarting the wizard" + f"Existing setup detected, please delete {rconfig_file} before restarting the wizard" ) sys.exit(2) @@ -58,12 +57,14 @@ def main() -> None: with config_file.open("w") as f: f.write(out) + proj_name = os.getenv("MICROBLOGPUB_WIZARD_PROJECT_NAME", "microblogpub") + env = { "WEB_PORT": 5005, "CONFIG_DIR": "./config", "DATA_DIR": "./data", "POUSSETACHES_AUTH_KEY": binascii.hexlify(os.urandom(32)).decode(), - "COMPOSE_PROJECT_NAME": Path.cwd().name.replace(".", ""), + "COMPOSE_PROJECT_NAME": proj_name, } out2 = ""