diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000000000..03656d7c8 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,4 @@ +node_modules +front +services +!services/nginx/temp/nginx.conf \ No newline at end of file diff --git a/.gitignore b/.gitignore index 6843fa701..9a4c04b95 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,6 @@ node_modules dist/* -build npm-debug.log -docker-compose.yml .eslintcache -.env.json \ No newline at end of file +datasources.*.json +db.json \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index a89ae9307..e40fc1375 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,16 +1,24 @@ FROM vn-node -RUN mkdir /salix +ENV NODE_ENV test + WORKDIR /salix +COPY package.json . +COPY loopback loopback +RUN npm install --only=prod -COPY dist . -COPY modules . -#COPY node_modules . -COPY loopback . -COPY dist/webpack-assets.json loopback/client +COPY back back +COPY dist dist +COPY modules modules +COPY \ + modules.yml \ + LICENSE \ + README.md \ + ./ -RUN rm /etc/nginx/sites-enabled/default -COPY services/nginx/temp/nginx.conf /etc/nginx/sites-available/salix -RUN ln -s /etc/nginx/sites-available/salix /etc/nginx/sites-enabled/salix +WORKDIR /etc/nginx +COPY services/nginx/temp/nginx.conf sites-available/salix +RUN rm sites-enabled/default && ln -s ../sites-available/salix sites-enabled/salix -CMD ["pm2-docker", "./server/server.js"] +WORKDIR /salix +CMD ["pm2-docker", "./loopback/server/server.js"] diff --git a/docker-compose.tpl.yml b/docker-compose.tpl.yml deleted file mode 100644 index c64e6b98b..000000000 --- a/docker-compose.tpl.yml +++ /dev/null @@ -1,9 +0,0 @@ -version: '3.5' -services: - nginx: - privileged: true - build: - context: ./services/nginx - ports: - - 80:80 - links: [] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 000000000..fd64abc07 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,15 @@ +version: '3.5' +services: + salix: + build: + context: . + dockerfile: Dockerfile + ports: + - 80:80 + environment: + NODE_ENV: '${NODE_ENV}' + container_name: salix + image: 'salix:latest' + restart: unless-stopped + volumes: + - '/config:/config' diff --git a/gulpfile.js b/gulpfile.js index ce837dcb2..6b4f04109 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -142,7 +142,7 @@ gulp.task('install', () => { // Deployment gulp.task('build', ['clean'], async() => { - await runSequenceP(['routes', 'locales', 'webpack', 'docker-compose', 'nginx-conf']); + await runSequenceP(['routes', 'locales', 'webpack', 'nginx-conf']); }); gulp.task('docker-compose', async() => { @@ -202,8 +202,7 @@ gulp.task('docker-compose', async() => { gulp.task('build-clean', () => { const del = require('del'); const files = [ - `${buildDir}/*`, - `docker-compose.yml` + `${buildDir}/*` ]; return del(files, {force: true}); }); diff --git a/modules.yml b/modules.yml index 4ea8a6493..00c1bc0d3 100644 --- a/modules.yml +++ b/modules.yml @@ -7,6 +7,4 @@ route, agency, travel - # mailer - # print ] \ No newline at end of file diff --git a/services/.gitignore b/services/.gitignore deleted file mode 100644 index 0d44de994..000000000 --- a/services/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -datasources.*.json -db.json diff --git a/services/nginx/nginx.mst b/services/nginx/nginx.mst index 09c53e760..03e09eef9 100644 --- a/services/nginx/nginx.mst +++ b/services/nginx/nginx.mst @@ -1,37 +1,23 @@ -worker_processes 1; +server { + listen 80 default_server; + listen [::]:80 default_server; + server_name _; + autoindex off; -events { - worker_connections 1024; -} + root /usr/share/nginx/html; -http { - sendfile on; - gzip on; - default_type application/octet-stream; - resolver 127.0.0.1; - include /etc/nginx/mime.types; + {{#services}} + location ~ ^/{{.}}(?:/(.*))?$ { + proxy_pass http://127.0.0.1:{{defaultPort}}/$1$is_args$args; + } + {{/services}} - server { - listen 80 default_server; - listen [::]:80 default_server; - server_name _; - autoindex off; - - root /usr/share/nginx/html; - - {{#services}} - location ~ ^/{{name}}(?:/(.*))?$ { - proxy_pass http://localhost:{{defaultPort}}/$1$is_args$args; - } - {{/services}} - - location ~ ^/static(?:/(.*))?$ { - alias /salix/dist/$1; - autoindex on; - } - location ~ ^(?:/(.*))?$ { - proxy_pass http://localhost:{{defaultPort}}/$1$is_args$args; - } + location ~ ^/static(?:/(.*))?$ { + alias /salix/dist/$1; + autoindex on; + } + location ~ ^(?:/(.*))?$ { + proxy_pass http://127.0.0.1:{{defaultPort}}/$1$is_args$args; } }