├── app ├── .babelrc ├── package.json └── src │ └── index.js ├── docker-compose-example └── docker-compose.yml ├── .gitignore ├── start.sh ├── nginx └── default.conf ├── README.md ├── supervisord.conf ├── supervisord-dev.conf ├── Dockerfile ├── Dockerfile-LTS └── LICENSE /app/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["env", "stage-2"], 3 | "plugins": [] 4 | } 5 | -------------------------------------------------------------------------------- /app/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "App", 3 | "version": "1.0.0", 4 | "description": "App", 5 | "main": "index.js", 6 | "scripts": { 7 | "build": "babel src -d dist", 8 | "serve": "node dist/index.js" 9 | }, 10 | "author": "Sirinat Paphatsirinatthi", 11 | "license": "FINIZ", 12 | "dependencies": { 13 | "express": "^4.16.2" 14 | }, 15 | "devDependencies": { 16 | "babel-cli": "^6.26.0", 17 | "babel-preset-env": "^1.6.1", 18 | "babel-preset-stage-2": "^6.24.1", 19 | "nodemon": "^1.12.1" 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /app/src/index.js: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 Finiz Open Source Software 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. */ 14 | 15 | import express from 'express' 16 | 17 | const app = express() 18 | 19 | app.get('/', (req, res) => { 20 | res.send('Hello World') 21 | }) 22 | 23 | // listen on port 24 | const port = 3000; 25 | app.listen(port, () => { 26 | var listenerWelcomeMessage = `listening on ${port}` 27 | console.log(listenerWelcomeMessage) 28 | }) 29 | -------------------------------------------------------------------------------- /docker-compose-example/docker-compose.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2019 Finiz Open Source Software 2 | 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | version: '3' 16 | 17 | services: 18 | nginx-node: 19 | restart: always 20 | image: finizco/nginx-node:latest 21 | ports: 22 | - "8080:8080" 23 | environment: 24 | - NODE_PORT=3000 25 | - NODE_MODE=prod 26 | volumes: 27 | - ./app:/app 28 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | #Mac 2 | *.DS_Store 3 | 4 | # Logs 5 | logs 6 | *.log 7 | npm-debug.log* 8 | yarn-debug.log* 9 | yarn-error.log* 10 | 11 | #Build File 12 | app/dist 13 | 14 | # Runtime data 15 | pids 16 | *.pid 17 | *.seed 18 | *.pid.lock 19 | 20 | # Directory for instrumented libs generated by jscoverage/JSCover 21 | lib-cov 22 | 23 | # Coverage directory used by tools like istanbul 24 | coverage 25 | 26 | # nyc test coverage 27 | .nyc_output 28 | 29 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 30 | .grunt 31 | 32 | # Bower dependency directory (https://bower.io/) 33 | bower_components 34 | 35 | # node-waf configuration 36 | .lock-wscript 37 | 38 | # Compiled binary addons (http://nodejs.org/api/addons.html) 39 | build/Release 40 | 41 | # Dependency directories 42 | node_modules/ 43 | jspm_packages/ 44 | 45 | # Typescript v1 declaration files 46 | typings/ 47 | 48 | # Optional npm cache directory 49 | .npm 50 | 51 | # Optional eslint cache 52 | .eslintcache 53 | 54 | # Optional REPL history 55 | .node_repl_history 56 | 57 | # Output of 'npm pack' 58 | *.tgz 59 | 60 | # Yarn Integrity file 61 | .yarn-integrity 62 | 63 | # dotenv environment variables file 64 | .env 65 | -------------------------------------------------------------------------------- /start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Copyright 2019 Finiz Open Source Software 4 | 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | # Check NODE_PORT variable is exist 18 | 19 | if [[ -z "${NODE_PORT}" ]]; then 20 | NODE_PORT="3000" 21 | else 22 | NODE_PORT="${NODE_PORT}" 23 | fi 24 | 25 | # Map NODE_PORT to Nginx default.conf 26 | 27 | sed -i "s/___NODE_PORT___/$NODE_PORT/g" /etc/nginx/conf.d/default.conf 28 | 29 | # Update nginx to match worker_processes to no. of cpu's 30 | procs=$(cat /proc/cpuinfo |grep processor | wc -l) 31 | sed -i -e "s/worker_processes 1/worker_processes $procs/" /etc/nginx/nginx.conf 32 | 33 | # Always chown webroot for better mounting 34 | mkdir -p /usr/share/nginx/html 35 | chown -Rf nginx.nginx /usr/share/nginx/html 36 | 37 | # Start supervisord and services 38 | 39 | if [[ -z "${NODE_MODE}" ]]; then 40 | NODE_MODE="prod" 41 | else 42 | NODE_MODE="${NODE_MODE}" 43 | fi 44 | 45 | # Create Nginx pid 46 | mkdir -p /run/nginx 47 | 48 | if [[ "${NODE_MODE}" = "prod" ]]; then 49 | /usr/bin/supervisord -n -c /etc/supervisord.conf 50 | elif [[ "${NODE_MODE}" = "dev" ]]; then 51 | /usr/bin/supervisord -n -c /etc/supervisord-dev.conf 52 | fi 53 | -------------------------------------------------------------------------------- /nginx/default.conf: -------------------------------------------------------------------------------- 1 | # Copyright 2019 Finiz Open Source Software 2 | 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | server { 16 | listen 8080; 17 | 18 | #charset koi8-r; 19 | #access_log /var/log/nginx/host.access.log main; 20 | 21 | location / { 22 | proxy_pass http://127.0.0.1:___NODE_PORT___; 23 | proxy_http_version 1.1; 24 | proxy_set_header Upgrade $http_upgrade; 25 | proxy_set_header Connection 'upgrade'; 26 | proxy_set_header Host $host; 27 | proxy_cache_bypass $http_upgrade; 28 | } 29 | 30 | #error_page 404 /404.html; 31 | 32 | # redirect server error pages to the static page /50x.html 33 | # 34 | error_page 500 502 503 504 /50x.html; 35 | location = /50x.html { 36 | root /usr/share/nginx/html; 37 | } 38 | 39 | # proxy the PHP scripts to Apache listening on 127.0.0.1:80 40 | # 41 | #location ~ \.php$ { 42 | # proxy_pass http://127.0.0.1; 43 | #} 44 | 45 | # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 46 | # 47 | #location ~ \.php$ { 48 | # root html; 49 | # fastcgi_pass 127.0.0.1:9000; 50 | # fastcgi_index index.php; 51 | # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; 52 | # include fastcgi_params; 53 | #} 54 | 55 | # deny access to .htaccess files, if Apache's document root 56 | # concurs with nginx's one 57 | # 58 | #location ~ /\.ht { 59 | # deny all; 60 | #} 61 | } 62 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Introduction 2 | This is an Alpine based container image running Nginx reversing proxy with Node v11.x (Yarn Support) 3 | 4 | ### Versioning 5 | | Docker Tag | GitHub Release | Nginx Version | Node Version | Alpine Version | 6 | |-----|-------|-----|--------|--------| 7 | | latest | master | 1.12.2 | 11.9.0 | 3.9 | 8 | | latest-lts | master-lts | 1.12.2 | 10.15.1 LTS | 3.9 | 9 | 10 | ## Building from source 11 | To build from source you need to clone the git repo and run docker build: 12 | ``` 13 | $ git clone https://github.com/MOXGA-OSS/nginx-node-docker.git 14 | ``` 15 | 16 | followed by 17 | ``` 18 | $ docker build -t nginx-node:latest . 19 | ``` 20 | 21 | ## Pulling from Docker Hub 22 | ``` 23 | $ docker pull finizco/nginx-node:latest 24 | ``` 25 | 26 | ## Running 27 | To run the container: 28 | ``` 29 | $ docker run -p 8080:8080 -e "NODE_PORT=3000" -d finizco/nginx-node:latest 30 | ``` 31 | 32 | Default Node root: 33 | ``` 34 | /app 35 | ``` 36 | 37 | ## Installing Node App 38 | To install a Node app in the root, simply map the app volumes to running nginx-node container: 39 | 40 | ``` 41 | $ docker run -p 8080:8080 -e "NODE_PORT=3000" -v /app:/app -d finizco/nginx-node:latest 42 | ``` 43 | 44 | The Node app should has a serve script in its package.json 45 | 46 | ``` 47 | "scripts": { 48 | ..., 49 | "serve": "node dist/index.js" 50 | } 51 | ``` 52 | 53 | ## Running Node App on Production (PM2 is recommended) 54 | 55 | To run the app on clustering mode with PM2 (Node.JS Process Manager) for production, add "--no-daemon" after the PM2 serve script 56 | 57 | For Example: 58 | 59 | ``` 60 | "scripts": { 61 | ..., 62 | "serve": "pm2 start dist/index.js -i max --name app --no-daemon" 63 | } 64 | ``` 65 | 66 | ## Environment Variables 67 | 68 | NODE_PORT - A port that the Node app is listening on (default is 3000). 69 | 70 | NODE_MODE - A mode of the running Node app (Specify prod for production, dev for development, default is prod). 71 | 72 | ## Docker-Compose Example 73 | 74 | ``` 75 | version: '3' 76 | 77 | services: 78 | nginx-node: 79 | restart: always 80 | image: finizco/nginx-node:latest 81 | ports: 82 | - "8080:8080" 83 | environment: 84 | - NODE_PORT=3000 85 | - NODE_MODE=prod 86 | volumes: 87 | - /app:/app 88 | ``` 89 | ## License 90 | 91 | Nginx-Node-Docker is Apache Licensed. 92 | -------------------------------------------------------------------------------- /supervisord.conf: -------------------------------------------------------------------------------- 1 | ; Copyright 2019 Finiz Open Source Software 2 | 3 | ; Licensed under the Apache License, Version 2.0 (the "License"); 4 | ; you may not use this file except in compliance with the License. 5 | ; You may obtain a copy of the License at 6 | 7 | ; http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | ; Unless required by applicable law or agreed to in writing, software 10 | ; distributed under the License is distributed on an "AS IS" BASIS, 11 | ; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | ; See the License for the specific language governing permissions and 13 | ; limitations under the License. 14 | 15 | [unix_http_server] 16 | file=/tmp/supervisor.sock ; (the path to the socket file) 17 | username=nobody 18 | password=nobody 19 | 20 | [supervisord] 21 | logfile=/tmp/supervisord.log ; (main log file;default $CWD/supervisord.log) 22 | logfile_maxbytes=50MB ; (max main logfile bytes b4 rotation;default 50MB) 23 | logfile_backups=10 ; (num of main logfile rotation backups;default 10) 24 | loglevel=info ; (log level;default info; others: debug,warn,trace) 25 | pidfile=/tmp/supervisord.pid ; (supervisord pidfile;default supervisord.pid) 26 | nodaemon=false ; (start in foreground if true;default false) 27 | minfds=1024 ; (min. avail startup file descriptors;default 1024) 28 | minprocs=200 ; (min. avail process descriptors;default 200) 29 | user=root ; (default is current user, required if root) 30 | 31 | ; the below section must remain in the config file for RPC 32 | ; (supervisorctl/web interface) to work, additional interfaces may be 33 | ; added by defining them in separate rpcinterface: sections 34 | [rpcinterface:supervisor] 35 | supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface 36 | 37 | [supervisorctl] 38 | serverurl=unix:///tmp/supervisor.sock ; use a unix:// URL for a unix socket 39 | 40 | [program:app] 41 | command=npm run serve --prefix /app 42 | autostart=true 43 | autorestart=true 44 | priority=5 45 | stdout_events_enabled=true 46 | stderr_events_enabled=true 47 | stdout_logfile=/dev/stdout 48 | stdout_logfile_maxbytes=0 49 | stderr_logfile=/dev/stderr 50 | stderr_logfile_maxbytes=0 51 | environment=NODE_ENV="production" 52 | 53 | [program:nginx] 54 | command=/usr/sbin/nginx -g "daemon off;" 55 | autostart=true 56 | autorestart=true 57 | priority=10 58 | stdout_events_enabled=true 59 | stderr_events_enabled=true 60 | stdout_logfile=/dev/stdout 61 | stdout_logfile_maxbytes=0 62 | stderr_logfile=/dev/stderr 63 | stderr_logfile_maxbytes=0 64 | 65 | [eventlistener:stdout] 66 | command = supervisor_stdout 67 | buffer_size = 100 68 | events = PROCESS_LOG 69 | result_handler = supervisor_stdout:event_handler 70 | -------------------------------------------------------------------------------- /supervisord-dev.conf: -------------------------------------------------------------------------------- 1 | ; Copyright 2019 Finiz Open Source Software 2 | 3 | ; Licensed under the Apache License, Version 2.0 (the "License"); 4 | ; you may not use this file except in compliance with the License. 5 | ; You may obtain a copy of the License at 6 | 7 | ; http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | ; Unless required by applicable law or agreed to in writing, software 10 | ; distributed under the License is distributed on an "AS IS" BASIS, 11 | ; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | ; See the License for the specific language governing permissions and 13 | ; limitations under the License. 14 | 15 | [unix_http_server] 16 | file=/tmp/supervisor.sock ; (the path to the socket file) 17 | username=nobody 18 | password=nobody 19 | 20 | [supervisord] 21 | logfile=/tmp/supervisord.log ; (main log file;default $CWD/supervisord.log) 22 | logfile_maxbytes=50MB ; (max main logfile bytes b4 rotation;default 50MB) 23 | logfile_backups=10 ; (num of main logfile rotation backups;default 10) 24 | loglevel=info ; (log level;default info; others: debug,warn,trace) 25 | pidfile=/tmp/supervisord.pid ; (supervisord pidfile;default supervisord.pid) 26 | nodaemon=false ; (start in foreground if true;default false) 27 | minfds=1024 ; (min. avail startup file descriptors;default 1024) 28 | minprocs=200 ; (min. avail process descriptors;default 200) 29 | user=root ; (default is current user, required if root) 30 | 31 | ; the below section must remain in the config file for RPC 32 | ; (supervisorctl/web interface) to work, additional interfaces may be 33 | ; added by defining them in separate rpcinterface: sections 34 | [rpcinterface:supervisor] 35 | supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface 36 | 37 | [supervisorctl] 38 | serverurl=unix:///tmp/supervisor.sock ; use a unix:// URL for a unix socket 39 | 40 | [program:app-dev] 41 | command=npm run dev --prefix /app 42 | autostart=true 43 | autorestart=true 44 | priority=5 45 | stdout_events_enabled=true 46 | stderr_events_enabled=true 47 | stdout_logfile=/dev/stdout 48 | stdout_logfile_maxbytes=0 49 | stderr_logfile=/dev/stderr 50 | stderr_logfile_maxbytes=0 51 | environment=NODE_ENV="development" 52 | 53 | [program:nginx] 54 | command=/usr/sbin/nginx -g "daemon off;" 55 | autostart=true 56 | autorestart=true 57 | priority=10 58 | stdout_events_enabled=true 59 | stderr_events_enabled=true 60 | stdout_logfile=/dev/stdout 61 | stdout_logfile_maxbytes=0 62 | stderr_logfile=/dev/stderr 63 | stderr_logfile_maxbytes=0 64 | 65 | [eventlistener:stdout] 66 | command = supervisor_stdout 67 | buffer_size = 100 68 | events = PROCESS_LOG 69 | result_handler = supervisor_stdout:event_handler 70 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | # Copyright 2019 Finiz Open Source Software 2 | 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # From Alpine official image 16 | FROM alpine:latest 17 | 18 | # Maintainer 19 | LABEL maintainer="Finiz Open Source Software " 20 | 21 | # Update apk repositories to be latest 22 | RUN apk update 23 | 24 | # Install git 25 | RUN apk add git 26 | 27 | # Install and config Supervisor 28 | RUN apk add python py2-pip 29 | RUN pip install wheel 30 | RUN pip install supervisor supervisor-stdout 31 | ADD ./supervisord.conf /etc/supervisord.conf 32 | ADD ./supervisord-dev.conf /etc/supervisord-dev.conf 33 | 34 | # Avoid ERROR: invoke-rc.d: policy-rc.d denied execution of start. 35 | RUN echo "#!/bin/sh\nexit 0" > /usr/sbin/policy-rc.d 36 | 37 | # Install Nginx 38 | RUN apk add nginx 39 | 40 | # Override Nginx's default config 41 | RUN rm -rf /etc/nginx/conf.d/default.conf 42 | ADD nginx/default.conf /etc/nginx/conf.d/default.conf 43 | 44 | # Build Node.js 11.x 45 | ENV NODE_VERSION 11.9.0 46 | 47 | RUN addgroup -g 1000 node \ 48 | && adduser -u 1000 -G node -s /bin/sh -D node \ 49 | && apk add --no-cache \ 50 | libstdc++ \ 51 | && apk add --no-cache --virtual .build-deps \ 52 | binutils-gold \ 53 | curl \ 54 | g++ \ 55 | gcc \ 56 | gnupg \ 57 | libgcc \ 58 | linux-headers \ 59 | make \ 60 | python \ 61 | # gpg keys listed at https://github.com/nodejs/node#release-keys 62 | && for key in \ 63 | 94AE36675C464D64BAFA68DD7434390BDBE9B9C5 \ 64 | FD3A5288F042B6850C66B31F09FE44734EB7990E \ 65 | 71DCFD284A79C3B38668286BC97EC7A07EDE3FC1 \ 66 | DD8F2338BAE7501E3DD5AC78C273792F7D83545D \ 67 | C4F0DFFF4E8C1A8236409D08E73BC641CC11F4C8 \ 68 | B9AE9905FFD7803F25714661B63B535A4C206CA9 \ 69 | 77984A986EBC2AA786BC0F66B01FBB92821C587A \ 70 | 8FCCA13FEF1D0C2E91008E09770F7A9A5AE15600 \ 71 | 4ED778F539E3634C779C87C6D7062848A1AB005C \ 72 | A48C2BEE680E841632CD4E44F07496B3EB3C1762 \ 73 | B9E2F5981AA6E0CD28160D9FF13993A75599653C \ 74 | ; do \ 75 | gpg --batch --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys "$key" || \ 76 | gpg --batch --keyserver hkp://ipv4.pool.sks-keyservers.net --recv-keys "$key" || \ 77 | gpg --batch --keyserver hkp://pgp.mit.edu:80 --recv-keys "$key" ; \ 78 | done \ 79 | && curl -fsSLO --compressed "https://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION.tar.xz" \ 80 | && curl -fsSLO --compressed "https://nodejs.org/dist/v$NODE_VERSION/SHASUMS256.txt.asc" \ 81 | && gpg --batch --decrypt --output SHASUMS256.txt SHASUMS256.txt.asc \ 82 | && grep " node-v$NODE_VERSION.tar.xz\$" SHASUMS256.txt | sha256sum -c - \ 83 | && tar -xf "node-v$NODE_VERSION.tar.xz" \ 84 | && cd "node-v$NODE_VERSION" \ 85 | && ./configure \ 86 | && make -j$(getconf _NPROCESSORS_ONLN) \ 87 | && make install \ 88 | && apk del .build-deps \ 89 | && cd .. \ 90 | && rm -Rf "node-v$NODE_VERSION" \ 91 | && rm "node-v$NODE_VERSION.tar.xz" SHASUMS256.txt.asc SHASUMS256.txt 92 | 93 | # Build Yarn Package Manager 1.13.x 94 | 95 | ENV YARN_VERSION 1.13.0 96 | 97 | RUN apk add --no-cache --virtual .build-deps-yarn curl gnupg tar \ 98 | && for key in \ 99 | 6A010C5166006599AA17F08146C2130DFD2497F5 \ 100 | ; do \ 101 | gpg --batch --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys "$key" || \ 102 | gpg --batch --keyserver hkp://ipv4.pool.sks-keyservers.net --recv-keys "$key" || \ 103 | gpg --batch --keyserver hkp://pgp.mit.edu:80 --recv-keys "$key" ; \ 104 | done \ 105 | && curl -fsSLO --compressed "https://yarnpkg.com/downloads/$YARN_VERSION/yarn-v$YARN_VERSION.tar.gz" \ 106 | && curl -fsSLO --compressed "https://yarnpkg.com/downloads/$YARN_VERSION/yarn-v$YARN_VERSION.tar.gz.asc" \ 107 | && gpg --batch --verify yarn-v$YARN_VERSION.tar.gz.asc yarn-v$YARN_VERSION.tar.gz \ 108 | && mkdir -p /opt \ 109 | && tar -xzf yarn-v$YARN_VERSION.tar.gz -C /opt/ \ 110 | && ln -s /opt/yarn-v$YARN_VERSION/bin/yarn /usr/local/bin/yarn \ 111 | && ln -s /opt/yarn-v$YARN_VERSION/bin/yarnpkg /usr/local/bin/yarnpkg \ 112 | && rm yarn-v$YARN_VERSION.tar.gz.asc yarn-v$YARN_VERSION.tar.gz \ 113 | && apk del .build-deps-yarn 114 | 115 | # Add Node.js app 116 | COPY app /app 117 | 118 | # Install app packages 119 | WORKDIR /app 120 | 121 | RUN yarn 122 | 123 | # Build app packages 124 | RUN yarn build 125 | 126 | # Install Bash Shell 127 | RUN apk add --update bash 128 | 129 | # Clean up 130 | RUN rm -rf /var/cache/apk/* 131 | 132 | # Add a startup script 133 | ADD ./start.sh /start.sh 134 | RUN chmod 755 /start.sh 135 | 136 | # Expose Nginx port 137 | EXPOSE 8080 138 | 139 | # Run the startup script 140 | WORKDIR / 141 | 142 | CMD ["/start.sh"] 143 | -------------------------------------------------------------------------------- /Dockerfile-LTS: -------------------------------------------------------------------------------- 1 | # Copyright 2019 Finiz Open Source Software 2 | 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # From Alpine official image 16 | FROM alpine:latest 17 | 18 | # Maintainer 19 | LABEL maintainer="Finiz Open Source Software " 20 | 21 | # Update apk repositories to be latest 22 | RUN apk update 23 | 24 | # Install git 25 | RUN apk add git 26 | 27 | # Install and config Supervisor 28 | RUN apk add python py2-pip 29 | RUN pip install wheel 30 | RUN pip install supervisor supervisor-stdout 31 | ADD ./supervisord.conf /etc/supervisord.conf 32 | ADD ./supervisord-dev.conf /etc/supervisord-dev.conf 33 | 34 | # Avoid ERROR: invoke-rc.d: policy-rc.d denied execution of start. 35 | RUN echo "#!/bin/sh\nexit 0" > /usr/sbin/policy-rc.d 36 | 37 | # Install Nginx 38 | RUN apk add nginx 39 | 40 | # Override Nginx's default config 41 | RUN rm -rf /etc/nginx/conf.d/default.conf 42 | ADD nginx/default.conf /etc/nginx/conf.d/default.conf 43 | 44 | # Build Node.js 10.15.x 45 | 46 | ENV NODE_VERSION 10.15.1 47 | 48 | RUN addgroup -g 1000 node \ 49 | && adduser -u 1000 -G node -s /bin/sh -D node \ 50 | && apk add --no-cache \ 51 | libstdc++ \ 52 | && apk add --no-cache --virtual .build-deps \ 53 | binutils-gold \ 54 | curl \ 55 | g++ \ 56 | gcc \ 57 | gnupg \ 58 | libgcc \ 59 | linux-headers \ 60 | make \ 61 | python \ 62 | # gpg keys listed at https://github.com/nodejs/node#release-keys 63 | && for key in \ 64 | 94AE36675C464D64BAFA68DD7434390BDBE9B9C5 \ 65 | FD3A5288F042B6850C66B31F09FE44734EB7990E \ 66 | 71DCFD284A79C3B38668286BC97EC7A07EDE3FC1 \ 67 | DD8F2338BAE7501E3DD5AC78C273792F7D83545D \ 68 | C4F0DFFF4E8C1A8236409D08E73BC641CC11F4C8 \ 69 | B9AE9905FFD7803F25714661B63B535A4C206CA9 \ 70 | 77984A986EBC2AA786BC0F66B01FBB92821C587A \ 71 | 8FCCA13FEF1D0C2E91008E09770F7A9A5AE15600 \ 72 | 4ED778F539E3634C779C87C6D7062848A1AB005C \ 73 | A48C2BEE680E841632CD4E44F07496B3EB3C1762 \ 74 | B9E2F5981AA6E0CD28160D9FF13993A75599653C \ 75 | ; do \ 76 | gpg --batch --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys "$key" || \ 77 | gpg --batch --keyserver hkp://ipv4.pool.sks-keyservers.net --recv-keys "$key" || \ 78 | gpg --batch --keyserver hkp://pgp.mit.edu:80 --recv-keys "$key" ; \ 79 | done \ 80 | && curl -fsSLO --compressed "https://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION.tar.xz" \ 81 | && curl -fsSLO --compressed "https://nodejs.org/dist/v$NODE_VERSION/SHASUMS256.txt.asc" \ 82 | && gpg --batch --decrypt --output SHASUMS256.txt SHASUMS256.txt.asc \ 83 | && grep " node-v$NODE_VERSION.tar.xz\$" SHASUMS256.txt | sha256sum -c - \ 84 | && tar -xf "node-v$NODE_VERSION.tar.xz" \ 85 | && cd "node-v$NODE_VERSION" \ 86 | && ./configure \ 87 | && make -j$(getconf _NPROCESSORS_ONLN) \ 88 | && make install \ 89 | && apk del .build-deps \ 90 | && cd .. \ 91 | && rm -Rf "node-v$NODE_VERSION" \ 92 | && rm "node-v$NODE_VERSION.tar.xz" SHASUMS256.txt.asc SHASUMS256.txt 93 | 94 | # Build Yarn Package Manager 1.13.x 95 | 96 | ENV YARN_VERSION 1.13.0 97 | 98 | RUN apk add --no-cache --virtual .build-deps-yarn curl gnupg tar \ 99 | && for key in \ 100 | 6A010C5166006599AA17F08146C2130DFD2497F5 \ 101 | ; do \ 102 | gpg --batch --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys "$key" || \ 103 | gpg --batch --keyserver hkp://ipv4.pool.sks-keyservers.net --recv-keys "$key" || \ 104 | gpg --batch --keyserver hkp://pgp.mit.edu:80 --recv-keys "$key" ; \ 105 | done \ 106 | && curl -fsSLO --compressed "https://yarnpkg.com/downloads/$YARN_VERSION/yarn-v$YARN_VERSION.tar.gz" \ 107 | && curl -fsSLO --compressed "https://yarnpkg.com/downloads/$YARN_VERSION/yarn-v$YARN_VERSION.tar.gz.asc" \ 108 | && gpg --batch --verify yarn-v$YARN_VERSION.tar.gz.asc yarn-v$YARN_VERSION.tar.gz \ 109 | && mkdir -p /opt \ 110 | && tar -xzf yarn-v$YARN_VERSION.tar.gz -C /opt/ \ 111 | && ln -s /opt/yarn-v$YARN_VERSION/bin/yarn /usr/local/bin/yarn \ 112 | && ln -s /opt/yarn-v$YARN_VERSION/bin/yarnpkg /usr/local/bin/yarnpkg \ 113 | && rm yarn-v$YARN_VERSION.tar.gz.asc yarn-v$YARN_VERSION.tar.gz \ 114 | && apk del .build-deps-yarn 115 | 116 | # Add Node.js app 117 | COPY app /app 118 | 119 | # Install app packages 120 | WORKDIR /app 121 | 122 | RUN yarn 123 | 124 | # Build app packages 125 | RUN yarn build 126 | 127 | # Install Bash Shell 128 | RUN apk add --update bash 129 | 130 | # Clean up 131 | RUN rm -rf /var/cache/apk/* 132 | 133 | # Add a startup script 134 | ADD ./start.sh /start.sh 135 | RUN chmod 755 /start.sh 136 | 137 | # Expose Nginx port 138 | EXPOSE 8080 139 | 140 | # Run the startup script 141 | WORKDIR / 142 | 143 | CMD ["/start.sh"] 144 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | --------------------------------------------------------------------------------