Attempt to add dockerfile

This commit is contained in:
Esther 2021-02-15 01:45:26 +00:00
parent 32bdec59fe
commit 84c82f6a56
No known key found for this signature in database
GPG Key ID: 162A307C5EBD40EA
5 changed files with 33 additions and 6 deletions

2
.gitignore vendored
View File

@ -195,3 +195,5 @@ fabric.properties
.idea/caches/build_file_checksums.ser
notes
.secrets

2
app.js
View File

@ -13,7 +13,7 @@ var contactRouter = require('./routes/contact');
var app = express();
app.set('trust proxy', 'loopback,uniquelocal');
if (process.env.IS_DOCKER != 'true') app.set('trust proxy', 'loopback,uniquelocal');
app.disable('x-powered-by');
// view engine setup

View File

@ -14,7 +14,6 @@ var http = require('http');
var port = normalizePort(process.env.PORT || '7000');
app.set('port', port);
console.log(port)
/**
* Create HTTP server.
@ -26,7 +25,8 @@ var server = http.createServer(app);
* Listen on provided port, on all localhost.
*/
server.listen(port, 'localhost');
if (process.env.IS_DOCKER == 'true') server.listen(port, '0.0.0.0');
else server.listen(port, '127.0.0.1');
server.on('error', onError);
server.on('listening', onListening);

View File

@ -1,7 +1,10 @@
FROM node:15.8.0
ENV PORT=
ENV NODE_ENV=
ARG port =
ENV PORT=${port}
ENV IS_DOCKER=true
ENV NODE_ENV=production
ENV GHOST_KEY=
ENV HCAPTCHA_KEY=
ENV SENDGRID_API_KEY=
@ -15,4 +18,4 @@ RUN npm install
COPY . .
CMD [ "npm", "start" ]
EXPOSE 7000/tcp
EXPOSE ${port}/tcp

22
pastel-codes.service Normal file
View File

@ -0,0 +1,22 @@
[Unit]
Description="pastel.codes web service"
Documentation=https://pastel.codes.com
After=network.target
[Service]
Environment=PORT=7000
Environment=NODE_ENV=production
Environment=GHOST_KEY=key
Environment=HCAPTCHA_KEY=key
Environment=SENDGRID_API_KEY=key
Environment=TO_MAIL_USER=user
Environment=REPLY_TO_MAIL=user
Environment=FROM_MAIL_USER=user
StandardOutput=syslog
SyslogIdentifier=pastel-codes
User=web
ExecStart=/home/web/pastel.codes/bin/www
Restart=always
[Install]
WantedBy=multi-user.target