Skip to content
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

Update Docker containers to be multi-part #874

Closed
maxxcrawford opened this issue Jun 11, 2021 · 1 comment
Closed

Update Docker containers to be multi-part #874

maxxcrawford opened this issue Jun 11, 2021 · 1 comment

Comments

@maxxcrawford
Copy link
Contributor

maxxcrawford commented Jun 11, 2021

Currently we have one big container with Python AND Node. We should switch this out to multi-part per @moz-astults recommendation.

To do this, we need to move django-gulp to be DEVmode only.

In the first container (node), we should install npm and run npm install and THEN run gulp to compile all the CSS. Copy over the compiled filed and then move on to the Python.

Note – @moz-astults made great progress down this path and we had to abandon it. See this commit for how it should work: 2429d53

@groovecoder
Copy link
Member

My read on multi-stage Dockerfiles suggests that the 2nd FROM python:3.7.9 directive starts a new container, so that python container doesn't have node, which collectstatic is trying to use. And that's why we get this error:

 => ERROR [stage-1 12/12] RUN python manage.py collectstatic --no-input -v 2                                     3.4s
------
 > [stage-1 12/12] RUN python manage.py collectstatic --no-input -v 2:
#22 3.289 /usr/bin/env: 'node': No such file or directory
#22 3.290 CommandError: Command 'gulp build --cwd /app --production' returned non-zero exit status 127.
------
executor failed running [/bin/sh -c python manage.py collectstatic --no-input -v 2]: exit code: 1

The main issue is that django-gulp makes collectstatic also run gulp. So it tightly couples the python & node commands to each other. 😢 I think what we'd like is to use django-gulp for local and heroku dev, but NOT use django-gulp for stage + prod. For stage + prod, we should be able to:

  1. FROM node:14 as gulp-image image, RUN npm install && gulp build
  2. COPY --from=gulp-image /app/static/* ./app/static
  3. FROM python:3.7.9 image, RUN python manage.py collectstatic

I'll see if I can get this working ...

groovecoder added a commit that referenced this issue Jun 16, 2021
 fix #874: run gulp in docker; not during collectstatic
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants