mirror of
https://github.com/cookiecutter/cookiecutter-django.git
synced 2025-08-09 14:34:53 +03:00
Add multi-stage docker build for production w/ node & python
This commit is contained in:
parent
1d674abe36
commit
ed43cd55ac
|
@ -1,3 +1,14 @@
|
||||||
|
{% if cookiecutter.js_task_runner == 'Gulp' -%}
|
||||||
|
FROM node:8-alpine as client-builder
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
COPY ./package.json /app
|
||||||
|
RUN npm install && npm cache clean --force
|
||||||
|
COPY . /app
|
||||||
|
RUN npm run build
|
||||||
|
|
||||||
|
# Python build stage
|
||||||
|
{%- endif %}
|
||||||
FROM python:3.6-alpine
|
FROM python:3.6-alpine
|
||||||
|
|
||||||
ENV PYTHONUNBUFFERED 1
|
ENV PYTHONUNBUFFERED 1
|
||||||
|
@ -28,7 +39,8 @@ COPY ./compose/production/django/start /start
|
||||||
RUN sed -i 's/\r//' /start
|
RUN sed -i 's/\r//' /start
|
||||||
RUN chmod +x /start
|
RUN chmod +x /start
|
||||||
RUN chown django /start
|
RUN chown django /start
|
||||||
{% if cookiecutter.use_celery == "y" %}
|
|
||||||
|
{%- if cookiecutter.use_celery == "y" %}
|
||||||
COPY ./compose/production/django/celery/worker/start /start-celeryworker
|
COPY ./compose/production/django/celery/worker/start /start-celeryworker
|
||||||
RUN sed -i 's/\r//' /start-celeryworker
|
RUN sed -i 's/\r//' /start-celeryworker
|
||||||
RUN chmod +x /start-celeryworker
|
RUN chmod +x /start-celeryworker
|
||||||
|
@ -42,8 +54,13 @@ RUN chown django /start-celerybeat
|
||||||
COPY ./compose/production/django/celery/flower/start /start-flower
|
COPY ./compose/production/django/celery/flower/start /start-flower
|
||||||
RUN sed -i 's/\r//' /start-flower
|
RUN sed -i 's/\r//' /start-flower
|
||||||
RUN chmod +x /start-flower
|
RUN chmod +x /start-flower
|
||||||
{% endif %}
|
{%- endif %}
|
||||||
|
|
||||||
|
{%- if cookiecutter.js_task_runner == 'Gulp' %}
|
||||||
|
COPY --from=client-builder /app /app
|
||||||
|
{% else %}
|
||||||
COPY . /app
|
COPY . /app
|
||||||
|
{%- endif %}
|
||||||
|
|
||||||
RUN chown -R django /app
|
RUN chown -R django /app
|
||||||
|
|
||||||
|
|
|
@ -137,6 +137,20 @@ gulp.task('watch', function() {
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Build task
|
||||||
|
gulp.task('build',
|
||||||
|
[
|
||||||
|
'styles',
|
||||||
|
'scripts',
|
||||||
|
{%- if cookiecutter.custom_bootstrap_compilation == 'y' %}
|
||||||
|
'vendor-scripts',
|
||||||
|
{%- endif %}
|
||||||
|
'imgCompression'
|
||||||
|
],
|
||||||
|
function () {
|
||||||
|
console.log('Build complete!')
|
||||||
|
});
|
||||||
|
|
||||||
// Default task
|
// Default task
|
||||||
gulp.task('default', function() {
|
gulp.task('default', function() {
|
||||||
runSequence(
|
runSequence(
|
||||||
|
|
|
@ -34,7 +34,8 @@
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
{% if cookiecutter.js_task_runner == 'Gulp' -%}
|
{% if cookiecutter.js_task_runner == 'Gulp' -%}
|
||||||
"dev": "gulp"
|
"dev": "gulp",
|
||||||
|
"build": "gulp build"
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user