Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions compose.near-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ services:
- ol-build:/openlibrary/static/build
- ol-nodemodules:/openlibrary/node_modules
- ${OL_MOUNT_DIR:-.}:/openlibrary
- ol-pycache:/pycache
networks:
- webnet
- dbnet
Expand Down
9 changes: 9 additions & 0 deletions compose.override.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ services:
# The above volume mounts are required so that the local dev bind mount below
# does not clobber the data generated inside the image / container
- ${OL_MOUNT_DIR:-.}:/openlibrary
# Writable pyc bytecode cache dir -- see PYTHONPYCACHEPREFIX in
# Dockerfile.olbase for why this is needed.
- ol-pycache:/pycache
environment:
- LOCAL_DEV=true
- OL_EXPOSE_SOLR_INTERNALS_PARAMS=true
Expand All @@ -43,6 +46,7 @@ services:
# Persistent volume mount for generated css and js
- ol-build:/openlibrary/static/build
- ${OL_MOUNT_DIR:-.}:/openlibrary
- ol-pycache:/pycache
environment:
- LOCAL_DEV=true
- OL_EXPOSE_SOLR_INTERNALS_PARAMS=true
Expand Down Expand Up @@ -86,6 +90,7 @@ services:
# Persistent volume mount for installed git submodules
- ol-vendor:/openlibrary/vendor
- ${OL_MOUNT_DIR:-.}:/openlibrary
- ol-pycache:/pycache

db:
image: postgres:${POSTGRES_VERSION:-18.3}
Expand Down Expand Up @@ -118,6 +123,7 @@ services:
volumes:
- ol-vendor:/openlibrary/vendor
- ${OL_MOUNT_DIR:-.}:/openlibrary
- ol-pycache:/pycache

infobase:
build:
Expand All @@ -133,6 +139,7 @@ services:
volumes:
- ol-vendor:/openlibrary/vendor
- ${OL_MOUNT_DIR:-.}:/openlibrary
- ol-pycache:/pycache
depends_on:
db:
condition: service_healthy
Expand All @@ -158,6 +165,7 @@ services:
- ol-build:/openlibrary/static/build
- ol-nodemodules:/openlibrary/node_modules
- ${OL_MOUNT_DIR:-.}:/openlibrary
- ol-pycache:/pycache
# For OSP download persistence across restarts
- solr-updater-data:/solr-updater-data
depends_on:
Expand Down Expand Up @@ -189,3 +197,4 @@ volumes:
ol-build:
ol-nodemodules:
ol-postgres:
ol-pycache:
5 changes: 5 additions & 0 deletions compose.staging.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ services:
# The above volume mounts are required so that the local dev bind mount below
# does not clobber the data generated inside the image / container
- .:/openlibrary
# Writable pyc bytecode cache dir -- see PYTHONPYCACHEPREFIX in
# Dockerfile.olbase for why this is needed.
- ol-pycache:/pycache

fast_web:
build:
Expand All @@ -52,6 +55,7 @@ services:
# Persistent volume mount for generated css and js
- ol-build:/openlibrary/static/build
- .:/openlibrary
- ol-pycache:/pycache


memcached:
Expand All @@ -61,3 +65,4 @@ volumes:
ol-vendor:
ol-build:
ol-nodemodules:
ol-pycache:
17 changes: 14 additions & 3 deletions docker/Dockerfile.olbase
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,10 @@ RUN chmod 644 /usr/lib/nginx/modules/ngx_http_modsecurity_module.so \
RUN mkdir -p /var/log/openlibrary /var/lib/openlibrary && chown openlibrary:openlibrary /var/log/openlibrary /var/lib/openlibrary \
&& mkdir /openlibrary && chown openlibrary:openlibrary /openlibrary \
&& mkdir -p /var/lib/coverstore && chown openlibrary:openlibrary /var/lib/coverstore \
# In order to write to solr-updater's named volume, this needs to be
# pre-created with the right permissions
&& mkdir -p /solr-updater-data && chown openlibrary:openlibrary /solr-updater-data
# For the container to have write permissions to the ol-* named volumes, they need
# to be pre-created with the right permissions
&& mkdir -p /solr-updater-data && chown openlibrary:openlibrary /solr-updater-data \
&& mkdir -p /pycache && chown openlibrary:openlibrary /pycache
WORKDIR /openlibrary

USER openlibrary
Expand All @@ -79,10 +80,20 @@ RUN uv pip install -r requirements.txt

USER openlibrary

# The code volume mount doesn't have write access from the container on linux,
# So need to redirect pyc bytecode caching here instead of alongside sources.
ENV PYTHONPYCACHEPREFIX=/pycache

COPY --chown=openlibrary:openlibrary package*.json ./
RUN npm ci --no-audit

COPY --chown=openlibrary:openlibrary . /openlibrary
# run make to initialize git submodules, build css and js files
RUN ln -s vendor/infogami/infogami infogami \
&& make

# Pre-warm the pyc bytecode cache so it ships baked into the image.
RUN python -m compileall -q \
-x '/node_modules/' \
"$(python -c 'import sysconfig; print(sysconfig.get_path("purelib"))')" \
/openlibrary