Skip to content
This repository was archived by the owner on Jun 30, 2024. It is now read-only.

Commit 34e8171

Browse files
committed
Fix: Do not try to run alembic in production
1 parent 4754eea commit 34e8171

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

docker/docker_tools.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#
1818
# - Single-container: these commands creates a container designed to execute on a single server. The Dockerized applications associated with it include Jobe, Redis, and Postgres. A volume is used to persist data, such as updates to the server.
1919
#
20-
# - Production mode (the default): ``docker-tool build --single`` creates a container designed for production (which includes obtaining an HTTPS certificate).
20+
# - Production mode (the default): ``docker-tools build --single`` creates a container designed for production (which includes obtaining an HTTPS certificate).
2121
#
2222
# - Development mode: ``docker-tools build --single-dev`` creates a container supporting a development mode, which provides additional tools and installs the BookServer and Runestone Components from github, instead of from releases on PyPI.
2323
#
@@ -868,6 +868,7 @@ def _build_phase_1(
868868
# ``sphinxcontrib.paverutils.run_sphinx`` lacks venv support -- it doesn't use ``sys.executable``, so it doesn't find ``sphinx-build`` in the system path when executing ``/srv/venv/bin/runestone`` directly, instead of activating the venv first (where it does work). As a huge, ugly hack, symlink it to make it available in the system path.
869869
"ln -sf $RUNESTONE_PATH/.venv/bin/sphinx-build /usr/local/bin",
870870
# Deal with a different subdirectory layout inside the container (mandated by web2py) and outside the container by adding these symlinks.
871+
# TODO: should only do this in dev
871872
"ln -sf $BOOK_SERVER_PATH $WEB2PY_PATH/applications/BookServer",
872873
# We can't use ``$BOOK_SERVER_PATH`` here, since we need ``/srv/bookserver-dev`` in lowercase, not CamelCase.
873874
"ln -sf /srv/bookserver-dev $WEB2PY_PATH/applications/bookserver-dev",
@@ -1044,7 +1045,9 @@ def _build_phase_2_core(
10441045
xqt("rm -f $RUNESTONE_PATH/databases/*")
10451046
print("Populating database...")
10461047
xqt("rsmanage initdb --force", cwd=env.WEB2PY_PATH)
1047-
xqt("alembic stamp head", cwd=env.BOOK_SERVER_PATH)
1048+
# Should only use alembic in dev mode.
1049+
if build_config.is_dev():
1050+
xqt("alembic stamp head", cwd=env.BOOK_SERVER_PATH)
10481051
else:
10491052
print("Database already populated.")
10501053
# TODO: any checking to see if the db is healthy? Perhaps run Alembic autogenerate to see if it wants to do anything?

docker/docker_tools_misc.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ def start_servers(dev: bool) -> None:
7373
def _start_servers(dev: bool) -> None:
7474
ensure_in_docker()
7575
bs_config = os.environ.get("BOOK_SERVER_CONFIG", "production")
76+
w2p_config = os.environ.get("WEB2PY_CONFIG", "production")
77+
if bs_config != w2p_config:
78+
raise ValueError("web2py and bookserver configs do not match")
79+
7680
if bs_config == "development":
7781
dev = True
7882

0 commit comments

Comments
 (0)