1
0
Fork 0
mirror of https://github.com/SunRed/haste-server.git synced 2024-11-23 09:50:17 +01:00

Add Docker support and change default listening address

* Add Dockerfile
* Add docker-compose.yml
* Set default host address to null to make expressjs listen on both ipv4 and ipv6
This commit is contained in:
Manuel 2021-02-12 14:20:17 +01:00
parent 592e484d35
commit 4e668e0636
Signed by: Manuel
GPG key ID: 4085037435E1F07A
4 changed files with 59 additions and 4 deletions

33
Dockerfile Normal file
View file

@ -0,0 +1,33 @@
FROM node:lts-alpine
RUN apk add --no-cache curl
RUN mkdir -p /usr/src/app && \
chown node:node /usr/src/app
USER node:node
WORKDIR /usr/src/app
COPY --chown=node:node . .
RUN npm run build
# uncomment dbms client packages here
#RUN npm install pg@8.5.1 && \
# npm install aws-sdk@2.842.0 && \
# npm install memcached@2.2.2 && \
# npm install mongodb@3.6.4 && \
# npm install ioredis@4.22.0 && \
# npm install rethinkdbdash@2.3.31
ENV PORT=7777
EXPOSE ${PORT}
STOPSIGNAL SIGINT
ENTRYPOINT [ "node", "server.js" ]
HEALTHCHECK --interval=30s --timeout=5s --start-period=5s \
--retries=1 CMD curl -sS -o /dev/null localhost:${PORT} || exit 1
CMD [ "npm", "start" ]

21
docker-compose.yml Normal file
View file

@ -0,0 +1,21 @@
services:
haste-server:
build:
context: .
dockerfile: Dockerfile
image: zneix/haste-server
container_name: haste-server
network_mode: "bridge"
volumes:
# Default place to put files, can be removed with other storage system
- ./data:/usr/src/app/data:rw
# Create config.js from the example config and make changes
- ./config.js:/usr/src/app/config.js:ro
# PostgreSQL unix socket connection for use with pg storage and postgres database on host
#- /var/run/postgresql:/var/run/postgresql:rw
ports:
- "127.0.0.1:7777:7777/tcp"
- "::1:7777:7777/tcp"
restart: unless-stopped

View file

@ -1,7 +1,8 @@
module.exports = {
//address and port to which server will bind, host can also be a hostname
"host": "127.0.0.1",
"port": 7777,
//by default it will listen on all ipv4 and ipv6 addresses on port 7777
//"host": "127.0.0.1",
//"port": 7777,
//length of random characters in link that's generated on document save
"keyLength": 10,

View file

@ -21,7 +21,7 @@ const utils = new HasteUtils();
//load config and set some defaults
const config = require('./config');
config.host = process.env.HOST || config.host || '127.0.0.1';
config.host = process.env.HOST || config.host || null;
config.port = process.env.PORT || config.port || 7777;
//set up logger
@ -117,6 +117,6 @@ const utils = new HasteUtils();
index: 'index.html'
}));
app.listen(config.port, config.host, () => winston.info(`listening on ${config.host}:${config.port}`));
app.listen(config.port, config.host, () => winston.info(`listening on ${(config.host === null ? '' : config.host + ':')}${config.port}`));
})();