Last active
July 9, 2021 16:25
-
-
Save brunosaboia/538e8540b227e2c71f3e3d3645287405 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM node:14.8.0-stretch | |
ENV APPLICATION_DIR=/usr/src/app | |
ENV RETENTION_DAYS=7 | |
ENV PORT=7777 | |
ENV PATH="${APPLICATION_DIR}:${PATH}" | |
RUN mkdir -p ${APPLICATION_DIR} && \ | |
chown node:node ${APPLICATION_DIR} | |
WORKDIR ${APPLICATION_DIR} | |
COPY . . | |
RUN chmod +x *.sh | |
USER node:node | |
RUN wget https://github.com/seejohnrun/haste-server/archive/refs/heads/master.zip && \ | |
unzip master.zip && \ | |
cd haste-server-master && \ | |
mv * ../ && \ | |
cd .. && \ | |
rm -rf haste-server-master && \ | |
rm master.zip | |
RUN npm install --production | |
RUN npm audit fix | |
EXPOSE ${PORT} | |
STOPSIGNAL SIGINT | |
ENTRYPOINT [ "startup.sh" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
node@c6af0af2de66:/usr/src/app$ ps afx | |
PID TTY STAT TIME COMMAND | |
34 pts/0 Ss 0:00 /bin/bash | |
51 pts/0 R+ 0:00 \_ ps afx | |
1 ? Ss 0:00 /bin/bash /usr/src/app/startup.sh | |
11 ? Sl 0:00 npm | |
22 ? S 0:00 \_ sh -c node server.js | |
23 ? Sl 0:00 \_ node server.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
find ${APPLICATION_DIR}/data -type f -mtime +${RETENTION_DAYS} -delete |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
watch -n 1 -p /usr/src/app/remove-old-files.sh &>/dev/null & | |
watch -n 1 -p echo '1 sec elapsed...' &>/dev/null & | |
echo 'normal echo' | |
/usr/local/bin/npm run start |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
~/Work/bec on 🐳 v20.10.6 | |
➜ docker build . --tag haste-server --no-cache | |
[+] Building 15.0s (13/13) FINISHED | |
=> [internal] load build definition from Dockerfile 0.0s | |
=> => transferring dockerfile: 37B 0.0s | |
=> [internal] load .dockerignore 0.0s | |
=> => transferring context: 2B 0.0s | |
=> [internal] load metadata for docker.io/library/node:14.8.0-stretch 0.9s | |
=> CACHED [1/8] FROM docker.io/library/node:14.8.0-stretch@sha256:8b6401f8d15c900736a54a870994277b3de19ebd28cc483c497bf00d608e2a90 0.0s | |
=> [2/8] RUN mkdir -p /usr/src/app && chown node:node /usr/src/app 0.3s | |
=> [internal] load build context 0.0s | |
=> => transferring context: 100B 0.0s | |
=> [3/8] WORKDIR /usr/src/app 0.0s | |
=> [4/8] COPY . . 0.0s | |
=> [5/8] RUN chmod +x *.sh 0.4s | |
=> [6/8] RUN wget https://github.com/seejohnrun/haste-server/archive/refs/heads/master.zip && unzip master.zip && cd haste-server-master && 1.3s | |
~/Work/bec on 🐳 v20.10.6 | |
➜ docker build . --tag haste-server --no-cache | |
[+] Building 15.5s (13/13) FINISHED | |
=> [internal] load build definition from Dockerfile 0.0s | |
=> => transferring dockerfile: 37B 0.0s | |
=> [internal] load .dockerignore 0.0s | |
=> => transferring context: 2B 0.0s | |
=> [internal] load metadata for docker.io/library/node:14.8.0-stretch 0.9s | |
=> CACHED [1/8] FROM docker.io/library/node:14.8.0-stretch@sha256:8b6401f8d15c900736a54a870994277b3de19ebd28cc483c497bf00d608e2a90 0.0s | |
=> [internal] load build context 0.0s | |
=> => transferring context: 100B 0.0s | |
=> [2/8] RUN mkdir -p /usr/src/app && chown node:node /usr/src/app 0.3s | |
=> [3/8] WORKDIR /usr/src/app 0.0s | |
=> [4/8] COPY . . 0.0s | |
=> [5/8] RUN chmod +x *.sh 0.3s | |
=> [6/8] RUN wget https://github.com/seejohnrun/haste-server/archive/refs/heads/master.zip && unzip master.zip && cd haste-s 1.1s | |
=> [7/8] RUN npm install --production 5.5s | |
=> [8/8] RUN npm audit fix 6.4s | |
=> exporting to image 0.6s | |
=> => exporting layers 0.6s | |
=> => writing image sha256:bbe6564de2799e8269350ae1f0e658ae5cd9be468a90e11168001fc1bf4da349 0.0s | |
=> => naming to docker.io/library/haste-server 0.0s | |
Use 'docker scan' to run Snyk tests against images to find vulnerabilities and learn how to fix them | |
~/Work/bec on 🐳 v20.10.6 took 17s | |
➜ docker run -d -p 7777:7777 haste-server | |
a7c28bbea299cbfe8df847bb597092a9967dceb39081969afe10b1882f48a89b | |
~/Work/bec on 🐳 v20.10.6 took 2s | |
➜ docker exec -it $(docker ps | grep 'haste-server' | awk '{ print $1 }') /bin/bash | |
node@a7c28bbea299:/usr/src/app$ ps afx | |
PID TTY STAT TIME COMMAND | |
35 pts/0 Ss 0:00 /bin/bash | |
44 pts/0 R+ 0:00 \_ ps afx | |
1 ? Ss 0:00 /bin/bash /usr/src/app/startup.sh | |
12 ? Sl 0:00 npm | |
23 ? S 0:00 \_ sh -c node server.js | |
24 ? Sl 0:00 \_ node server.js | |
node@a7c28bbea299:/usr/src/app$ ./startup.sh | |
normal echo | |
> haste@0.1.0 start /usr/src/app | |
> node server.js | |
info: compressed application.js into application.min.js | |
info: loading static document name=about, path=./about.md | |
info: listening on 0.0.0.0:7777 | |
events.js:291 | |
throw er; // Unhandled 'error' event | |
^ | |
Error: listen EADDRINUSE: address already in use 0.0.0.0:7777 | |
at Server.setupListenHandle [as _listen2] (net.js:1316:16) | |
at listenInCluster (net.js:1364:12) | |
at doListen (net.js:1501:7) | |
at processTicksAndRejections (internal/process/task_queues.js:81:21) | |
Emitted 'error' event on Server instance at: | |
at emitErrorNT (net.js:1343:8) | |
at processTicksAndRejections (internal/process/task_queues.js:80:21) { | |
code: 'EADDRINUSE', | |
errno: -98, | |
syscall: 'listen', | |
address: '0.0.0.0', | |
port: 7777 | |
} | |
npm ERR! code ELIFECYCLE | |
npm ERR! errno 1 | |
npm ERR! haste@0.1.0 start: `node server.js` | |
npm ERR! Exit status 1 | |
npm ERR! | |
npm ERR! Failed at the haste@0.1.0 start script. | |
npm ERR! This is probably not a problem with npm. There is likely additional logging output above. | |
npm ERR! A complete log of this run can be found in: | |
npm ERR! /home/node/.npm/_logs/2021-07-09T16_24_19_044Z-debug.log | |
node@a7c28bbea299:/usr/src/app$ ps afx | |
PID TTY STAT TIME COMMAND | |
35 pts/0 Ss 0:00 /bin/bash | |
101 pts/0 R+ 0:00 \_ ps afx | |
1 ? Ss 0:00 /bin/bash /usr/src/app/startup.sh | |
12 ? Sl 0:00 npm | |
23 ? S 0:00 \_ sh -c node server.js | |
24 ? Sl 0:00 \_ node server.js | |
46 pts/0 S 0:00 watch -n 1 -p /usr/src/app/remove-old-files.sh | |
47 pts/0 S 0:00 watch -n 1 -p echo 1 sec elapsed... | |
node@a7c28bbea299:/usr/src/app$ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment