From b3bf791d3c7725e4f7f996180b66d8ce789e4b2f Mon Sep 17 00:00:00 2001 From: wodka Date: Mon, 1 Jul 2019 10:03:29 +0200 Subject: [PATCH] improve docker images, fix jsep and initial build --- Dockerfile | 63 +++++++++++++++++++++++++++++----------------- bower.json | 2 +- docker-compose.yml | 24 ++++++++---------- nginx/Dockerfile | 8 ++++++ server.js | 5 ++-- 5 files changed, 63 insertions(+), 39 deletions(-) diff --git a/Dockerfile b/Dockerfile index 97e1855d..9bbedc7c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,33 +4,16 @@ # Run: # docker run -it tellform-prod -FROM phusion/baseimage:0.9.19 +FROM node:10-alpine MAINTAINER Arielle Baldwynn -# Install Utilities -RUN apt-get update -q \ - && apt-get install -yqq \ - curl \ - ant \ - git \ - gcc \ - make \ - build-essential \ - libkrb5-dev \ - python \ - sudo \ - apt-utils \ - && apt-get clean \ - && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* - -# Install nodejs -RUN curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash - -RUN sudo apt-get install -yq nodejs \ - && apt-get clean \ - && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* +# Install some needed packages +RUN apk add --no-cache \ + git \ + && rm -rf /tmp/* # Install NPM Global Libraries -RUN npm install --quiet -g grunt bower pm2 && npm cache clean +RUN npm install --quiet -g grunt bower pm2 && npm cache clean --force WORKDIR /opt/tellform RUN mkdir -p /opt/tellform/public/lib @@ -47,6 +30,39 @@ COPY ./gruntfile.js /opt/tellform/gruntfile.js COPY ./server.js /opt/tellform/server.js COPY ./scripts/create_admin.js /opt/tellform/scripts/create_admin.js +# Set default ENV +ENV NODE_ENV=development +ENV SECRET_KEY=ChangeMeChangeMe +#ENV MONGODB_URI=mongodb://mongo/tellform +#ENV REDIS_URL=redis://redis:6379 +ENV PORT=5000 +ENV BASE_URL=localhost +ENV SOCKET_PORT=20523 +ENV SIGNUP_DISABLED=FALSE +ENV SUBDOMAINS_DISABLED=FALSE +ENV ENABLE_CLUSTER_MODE=FALSE +ENV MAILER_EMAIL_ID=tellform@localhost +ENV MAILER_PASSWORD= +ENV MAILER_FROM=tellform@localhost +ENV MAILER_SERVICE_PROVIDER= +ENV MAILER_SMTP_HOST= +ENV MAILER_SMTP_PORT= +ENV MAILER_SMTP_SECURE= + +ENV CREATE_ADMIN=FALSE +ENV ADMIN_EMAIL=admin@localhost +ENV ADMIN_USERNAME=root +ENV ADMIN_PASSWORD=root + +ENV APP_NAME=Tellform +ENV APP_KEYWORDS= +ENV APP_DESC= + +# optional ENV settings +ENV COVERALLS_REPO_TOKEN= +ENV GOOGLE_ANALYTICS_ID= +ENV RAVEN_DSN= + # Copies the local package.json file to the container # and utilities docker container cache to not needing to rebuild # and install node_modules/ everytime we build the docker, but only @@ -54,6 +70,7 @@ COPY ./scripts/create_admin.js /opt/tellform/scripts/create_admin.js # Add npm package.json COPY ./package.json /opt/tellform/package.json RUN npm install --only=production --quiet +RUN grunt build # Run TellForm server CMD ["node", "server.js"] diff --git a/bower.json b/bower.json index afdaec71..d351e104 100755 --- a/bower.json +++ b/bower.json @@ -37,7 +37,7 @@ "angular-translate": "~2.11.0", "ng-translate": "*", "deep-diff": "^0.3.4", - "jsep": "^0.3.1", + "jsep": "0.3.1", "ngclipboard": "^1.1.1", "mobile-detect": "^1.3.3", "socket.io-client": "^1.7.2", diff --git a/docker-compose.yml b/docker-compose.yml index f51c2573..4b619de0 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,31 +3,29 @@ services: redis: restart: always image: redis - volumes: - - "${PWD}/.env:/opt/tellform/.env" networks: - back-tier mongo: restart: always image: mongo volumes: - - "$ROOT/mongo:/data" + - ".data/mongo:/data" networks: - back-tier tellform: build: context: . - env_file: - - .env - volumes: - # - "${PWD}/.env:/opt/tellform/.env" - - .:/opt/tellform + environment: + CREATE_ADMIN: "TRUE" + MONGODB_URI: mongodb://mongo/tellform + REDIS_URL: redis://redis +# volumes: +# - .:/opt/tellform links: - mongo - redis ports: - "5000:5000" - # - "20523:20523" depends_on: - mongo - redis @@ -43,10 +41,10 @@ services: - "80:80" - "443:443" - "20523:20523" - env_file: - - .env - volumes: - - "$ROOT/certs:/certs" + environment: + NODE_ENV: development + #volumes: + # - "$ROOT/certs:/certs" # - ./nginx/conf.d:/etc/nginx/conf.d networks: - back-tier diff --git a/nginx/Dockerfile b/nginx/Dockerfile index 3184ee05..3959a099 100644 --- a/nginx/Dockerfile +++ b/nginx/Dockerfile @@ -8,4 +8,12 @@ RUN chmod +x /start.py RUN chmod +x /letsencrypt.py RUN chmod +x /config.py +ENV NODE_ENV=development +ENV PORT=5000 +ENV SOCKET_PORT=20523 +ENV TLS_FLAVOR=notls +ENV BASE_URL=localhost +ENV SUBDOMAIN_URL=*.localhost +ENV SOCKETS_URL=ws.localhost + CMD /start.py diff --git a/server.js b/server.js index 78aeefa6..276531b5 100755 --- a/server.js +++ b/server.js @@ -40,7 +40,8 @@ const smtpTransport = nodemailer.createTransport(config.mailer.options); smtpTransport.verify(function(error, success) { if (error) { console.error(chalk.red('Your mail configuration is incorrect: ' + error)); - process.exit(-1); + // verify but to abort! + // process.exit(-1); } }); @@ -48,7 +49,7 @@ smtpTransport.verify(function(error, success) { var app = require('./config/express')(db); //Create admin account -if (process.env.CREATE_ADMIN_ACCOUNT === 'TRUE') { +if (process.env.CREATE_ADMIN === 'TRUE') { var create_admin = require('./scripts/create_admin'); create_admin.run(app, db, function(err){