Skip to content

Docker on steroids #1681

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
15 changes: 12 additions & 3 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
**/.git
.secret_key
node_modules/
**/.git/
**/node_modules/
**/.ruff_cache/
**/__pycache__/
**/.github/
.venv/
.secret_key
slate/
service/
screenshots/
db/
dpkg/
build/
59 changes: 40 additions & 19 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -82,34 +82,55 @@ RUN --mount=type=cache,target=/root/.npm \
npm install --quiet -g webpack-cli@5.1.4
EOT

# Copy remaining files
COPY . ./
COPY nginx ./nginx
RUN <<EOT
# nginx setup
chmod 0644 ./nginx/crontab
ln -s ./nginx/crontab /var/spool/cron/crontabs/root
chmod +x ./nginx/letsencrypt-autogen.sh
EOT

# Defining this here allows for caching of previous layers.
ARG TEST_BUILD

COPY nodeodm ./nodeodm
RUN <<EOT
# Final build steps (in one roll to prevent too many layers).
# Setup cron
chmod 0644 ./nginx/crontab
ln -s ./nginx/crontab /var/spool/cron/crontabs/root
# NodeODM setup
chmod +x ./nginx/letsencrypt-autogen.sh
# Setup NodeODM (only relevant in TEST_BUILD).
./nodeodm/setup.sh
./nodeodm/cleanup.sh
# Run webpack build, Django setup and final cleanup
webpack --mode production
# Django setup
python manage.py collectstatic --noinput
python manage.py rebuildplugins
python manage.py translate build --safe
# Final cleanup
# Remove stale temp files
rm -rf /tmp/* /var/tmp/*
# Remove auto-generated secret key (happens on import of settings when none is defined)
rm /webodm/webodm/secret_key.py
EOT

# Copy Python code
COPY webodm ./webodm
COPY app ./app
COPY worker ./worker
COPY manage.py ./

# Compile Python code
RUN python -m compileall .

# Collect static files
RUN python manage.py collectstatic --noinput

# Rebuild plugins
COPY coreplugins ./coreplugins
RUN python manage.py rebuildplugins

# Render translations
COPY LOCALES ./
COPY locale ./locale
RUN python manage.py translate build --safe

# Webpack build of app
COPY webpack.config.js ./
RUN webpack --mode production

# Remove stale temp files and auto-generated secret key (happens on import of settings when none is defined)
RUN rm -rvf /tmp/* /var/tmp/* /webodm/webodm/secret_key.py

# Remaining remaining files from /
COPY . ./

FROM common AS app

# Modify PATH to prioritize venv, effectively activating venv
Expand Down
2 changes: 1 addition & 1 deletion app/scripts/extract_plugin_manifest_strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def extract_plugin_manifest_strings(plugins_dir, output):
print("Found %s manifest strings" % len(strings))
if len(strings) > 0:
with open(output, "w") as f:
f.write("// Auto-generated with extract_plugin_manifest_strings.py, do not edit!\n\n")
f.write("# Auto-generated with extract_plugin_manifest_strings.py, do not edit!\n\n")
f.write("from django.utils.translation import gettext as _\n")

for s in strings:
Expand Down
2 changes: 1 addition & 1 deletion app/translations/plugin_manifest_autogenerated.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Auto-generated with extract_plugin_manifest_strings.py, do not edit!
# Auto-generated with extract_plugin_manifest_strings.py, do not edit!

from django.utils.translation import gettext as _
_("Upload and tile ODM assets with Cesium ion.")
Expand Down