mirror of
https://github.com/cookiecutter/cookiecutter-django.git
synced 2025-08-10 06:54:52 +03:00
Change for docker-compose + Gulp
This commit is contained in:
parent
c6c8ca953a
commit
6c8a53df52
|
@ -0,0 +1,7 @@
|
||||||
|
FROM node:8-alpine
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
COPY ./package.json /app
|
||||||
|
|
||||||
|
RUN npm install && npm cache clean --force
|
|
@ -10,6 +10,9 @@ SECRET_KEY = env('DJANGO_SECRET_KEY', default='!!!SET DJANGO_SECRET_KEY!!!')
|
||||||
# https://docs.djangoproject.com/en/dev/ref/settings/#allowed-hosts
|
# https://docs.djangoproject.com/en/dev/ref/settings/#allowed-hosts
|
||||||
ALLOWED_HOSTS = [
|
ALLOWED_HOSTS = [
|
||||||
"localhost",
|
"localhost",
|
||||||
|
{ % - if cookiecutter.js_task_runner == 'Gulp' and cookiecutter.use_docker == 'y' %}
|
||||||
|
"django",
|
||||||
|
{%- endif %}
|
||||||
"0.0.0.0",
|
"0.0.0.0",
|
||||||
"127.0.0.1",
|
"127.0.0.1",
|
||||||
]
|
]
|
||||||
|
|
|
@ -60,9 +60,9 @@ gulp.task('styles', function() {
|
||||||
return gulp.src(paths.sass + '/project.scss')
|
return gulp.src(paths.sass + '/project.scss')
|
||||||
.pipe(sass({
|
.pipe(sass({
|
||||||
includePaths: [
|
includePaths: [
|
||||||
{% if cookiecutter.custom_bootstrap_compilation == 'y' %}
|
{%- if cookiecutter.custom_bootstrap_compilation == 'y' %}
|
||||||
paths.bootstrapSass,
|
paths.bootstrapSass,
|
||||||
{% endif %}
|
{%- endif %}
|
||||||
paths.sass
|
paths.sass
|
||||||
]
|
]
|
||||||
}).on('error', sass.logError))
|
}).on('error', sass.logError))
|
||||||
|
@ -84,8 +84,7 @@ gulp.task('scripts', function() {
|
||||||
.pipe(gulp.dest(paths.js));
|
.pipe(gulp.dest(paths.js));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
{%- if cookiecutter.custom_bootstrap_compilation == 'y' %}
|
||||||
{% if cookiecutter.custom_bootstrap_compilation == 'y' %}
|
|
||||||
// Vendor Javascript minification
|
// Vendor Javascript minification
|
||||||
gulp.task('vendor-scripts', function() {
|
gulp.task('vendor-scripts', function() {
|
||||||
return gulp.src(paths.vendorsJs)
|
return gulp.src(paths.vendorsJs)
|
||||||
|
@ -96,7 +95,7 @@ gulp.task('vendor-scripts', function() {
|
||||||
.pipe(rename({ suffix: '.min' }))
|
.pipe(rename({ suffix: '.min' }))
|
||||||
.pipe(gulp.dest(paths.js));
|
.pipe(gulp.dest(paths.js));
|
||||||
});
|
});
|
||||||
{% endif %}
|
{%- endif %}
|
||||||
|
|
||||||
// Image compression
|
// Image compression
|
||||||
gulp.task('imgCompression', function(){
|
gulp.task('imgCompression', function(){
|
||||||
|
@ -105,6 +104,7 @@ gulp.task('imgCompression', function(){
|
||||||
.pipe(gulp.dest(paths.images))
|
.pipe(gulp.dest(paths.images))
|
||||||
});
|
});
|
||||||
|
|
||||||
|
{%- if cookiecutter.use_docker == 'n' %}
|
||||||
// Run django server
|
// Run django server
|
||||||
gulp.task('runServer', function(cb) {
|
gulp.task('runServer', function(cb) {
|
||||||
var cmd = spawn('python', ['manage.py', 'runserver'], {stdio: 'inherit'});
|
var cmd = spawn('python', ['manage.py', 'runserver'], {stdio: 'inherit'});
|
||||||
|
@ -113,18 +113,23 @@ gulp.task('runServer', function(cb) {
|
||||||
cb(code);
|
cb(code);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
{%- endif %}
|
||||||
|
|
||||||
// Browser sync server for live reload
|
// Browser sync server for live reload
|
||||||
gulp.task('browserSync', function() {
|
gulp.task('browserSync', function() {
|
||||||
browserSync.init(
|
browserSync.init(
|
||||||
[paths.css + "/*.css", paths.js + "*.js", paths.templates + '*.html'], {
|
[paths.css + "/*.css", paths.js + "*.js", paths.templates + '*.html'], {
|
||||||
|
{%- if cookiecutter.use_docker == 'n' %}
|
||||||
proxy: "localhost:8000"
|
proxy: "localhost:8000"
|
||||||
|
{% else %}
|
||||||
|
proxy: "django:8000",
|
||||||
|
open: false
|
||||||
|
{%- endif %}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// Watch
|
// Watch
|
||||||
gulp.task('watch', function() {
|
gulp.task('watch', function() {
|
||||||
|
|
||||||
gulp.watch(paths.sass + '/*.scss', ['styles']);
|
gulp.watch(paths.sass + '/*.scss', ['styles']);
|
||||||
gulp.watch(paths.js + '/*.js', ['scripts']).on("change", reload);
|
gulp.watch(paths.js + '/*.js', ['scripts']).on("change", reload);
|
||||||
gulp.watch(paths.images + '/*', ['imgCompression']);
|
gulp.watch(paths.images + '/*', ['imgCompression']);
|
||||||
|
@ -134,5 +139,21 @@ gulp.task('watch', function() {
|
||||||
|
|
||||||
// Default task
|
// Default task
|
||||||
gulp.task('default', function() {
|
gulp.task('default', function() {
|
||||||
runSequence(['styles', 'scripts', {% if cookiecutter.custom_bootstrap_compilation == 'y' %}'vendor-scripts', {% endif %}'imgCompression'], ['runServer', 'browserSync', 'watch']);
|
runSequence(
|
||||||
|
[
|
||||||
|
'styles',
|
||||||
|
'scripts',
|
||||||
|
{%- if cookiecutter.custom_bootstrap_compilation == 'y' %}
|
||||||
|
'vendor-scripts',
|
||||||
|
{%- endif %}
|
||||||
|
'imgCompression'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
{%- if cookiecutter.use_docker == 'n' %}
|
||||||
|
'runServer',
|
||||||
|
{%- endif %}
|
||||||
|
'browserSync',
|
||||||
|
'watch'
|
||||||
|
]
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
|
@ -72,3 +72,22 @@ services:
|
||||||
command: /start-celerybeat
|
command: /start-celerybeat
|
||||||
|
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
|
{%- if cookiecutter.js_task_runner == 'Gulp' %}
|
||||||
|
|
||||||
|
node:
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: ./compose/local/node/Dockerfile
|
||||||
|
image: my_awesome_project_local_node
|
||||||
|
depends_on:
|
||||||
|
- django
|
||||||
|
volumes:
|
||||||
|
- .:/app
|
||||||
|
# http://jdlm.info/articles/2016/03/06/lessons-building-node-app-docker.html
|
||||||
|
- /app/node_modules
|
||||||
|
command: npm run dev
|
||||||
|
ports:
|
||||||
|
- "3000:3000"
|
||||||
|
- "3001:3001"
|
||||||
|
|
||||||
|
{%- endif %}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user