Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/share/container/health_check.js
8 changes: 4 additions & 4 deletions Containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ RUN mkdir -p /var/log/torrust/tracker

ENV ENV=/etc/profile
COPY --chmod=0555 ./share/container/entry_script_sh /usr/local/bin/entry.sh
COPY --chmod=0555 ./share/container/health_check.js /usr/local/bin/health_check.js

VOLUME ["/var/log/torrust/index-gui"]

Expand All @@ -58,7 +59,6 @@ ENTRYPOINT ["/usr/local/bin/entry.sh"]
FROM runtime as release
ENV RUNTIME="release"
COPY --from=test /app/.output /app/.output
#HEALTHCHECK --interval=5s --timeout=5s --start-period=3s --retries=3 \
# CMD /usr/bin/http_health_check http://localhost:${HEALTH_CHECK_API_PORT}/health_check \
# || exit 1
CMD [ "/nodejs/bin/node", "/app/.output/server/index.mjs" ]
HEALTHCHECK --interval=5s --timeout=5s --start-period=3s --retries=3 \
CMD /nodejs/bin/node /usr/local/bin/health_check.js ${INDEX_GUI_PORT} || exit 1
CMD [ "/nodejs/bin/node", "/app/.output/server/index.mjs" ]
4 changes: 1 addition & 3 deletions contrib/dev-tools/container/e2e/sqlite/run-e2e-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ cp .env.local .env || exit 1
./contrib/dev-tools/container/functions/wait_for_container_to_be_healthy.sh torrust-mysql-1 10 3 || exit 1
./contrib/dev-tools/container/functions/wait_for_container_to_be_healthy.sh torrust-tracker-1 10 3 || exit 1
./contrib/dev-tools/container/functions/wait_for_container_to_be_healthy.sh torrust-index-1 10 3 || exit 1

# Wait for the Index GUI to be ready
sleep 10
./contrib/dev-tools/container/functions/wait_for_container_to_be_healthy.sh torrust-index-gui-1 10 3 || exit 1

# Just to make sure that everything is up and running
docker ps
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"generate": "nuxt generate",
"preview": "nuxt preview",
"postinstall": "nuxt prepare",
"lint": "eslint --ext \".ts,.js,.vue\" --ignore-path .gitignore .",
"lintfix": "eslint --fix --ext \".ts,.js,.vue\" --ignore-path .gitignore .",
"lint": "eslint --ext \".ts,.js,.vue\" .",
"lintfix": "eslint --fix --ext \".ts,.js,.vue\" .",
"cypress:open": "cypress open",
"cypress:run": "cypress run"
},
Expand Down
2 changes: 2 additions & 0 deletions project-words.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
composables
Containerfile
daisyui
dinamically
dompurify
filedrag
filelist
HEALTHCHECK
heroicons
infohash
lintfix
Expand Down
40 changes: 40 additions & 0 deletions share/container/health_check.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*

This application is used to create a `HEALTHCHECK` instruction in the
`Dockerfile` or `Containerfile`.

Usage:

node health_check.js 3000
node health_check.js PORT

*/

const http = require("http");

// Retrieve the port number from the command-line arguments.
// Default to 3000 if no argument is provided
const port = process.argv[2] || "3000";

const options = {
host: "localhost",
port,
timeout: 2000
};

const request = http.request(options, (res) => {
console.log(`STATUS: ${res.statusCode}`);
if (res.statusCode === 200) {
process.exit(0);
}
else {
process.exit(1);
}
});

request.on("error", function (err) {
console.log("ERROR");
process.exit(1);
});

request.end();