mirror of
https://github.com/plankanban/planka.git
synced 2025-07-18 12:49:43 +02:00
feat: Add healthcheck for docker deployments
fix: Missing healthcheck.js fix: missing healthcheck.js fix: HEALTHCHECK command
This commit is contained in:
parent
77ba21c4a7
commit
2ceeb0a71a
4 changed files with 50 additions and 22 deletions
|
@ -38,6 +38,7 @@ WORKDIR /app
|
||||||
|
|
||||||
COPY --chown=node:node start.sh .
|
COPY --chown=node:node start.sh .
|
||||||
COPY --chown=node:node server .
|
COPY --chown=node:node server .
|
||||||
|
COPY --chown=node:node healthcheck.js .
|
||||||
|
|
||||||
RUN mv .env.sample .env
|
RUN mv .env.sample .env
|
||||||
|
|
||||||
|
@ -52,4 +53,7 @@ VOLUME /app/private/attachments
|
||||||
|
|
||||||
EXPOSE 1337
|
EXPOSE 1337
|
||||||
|
|
||||||
|
HEALTHCHECK --interval=10s --timeout=2s --start-period=15s \
|
||||||
|
CMD node ./healthcheck.js
|
||||||
|
|
||||||
CMD ["./start.sh"]
|
CMD ["./start.sh"]
|
||||||
|
|
|
@ -3,15 +3,7 @@ version: '3'
|
||||||
services:
|
services:
|
||||||
planka:
|
planka:
|
||||||
image: ghcr.io/plankanban/planka:master
|
image: ghcr.io/plankanban/planka:master
|
||||||
command: >
|
restart: on-failure
|
||||||
bash -c
|
|
||||||
"for i in `seq 1 30`; do
|
|
||||||
./start.sh &&
|
|
||||||
s=$$? && break || s=$$?;
|
|
||||||
echo \"Tried $$i times. Waiting 5 seconds...\";
|
|
||||||
sleep 5;
|
|
||||||
done; (exit $$s)"
|
|
||||||
restart: unless-stopped
|
|
||||||
volumes:
|
volumes:
|
||||||
- user-avatars:/app/public/user-avatars
|
- user-avatars:/app/public/user-avatars
|
||||||
- project-background-images:/app/public/project-background-images
|
- project-background-images:/app/public/project-background-images
|
||||||
|
@ -44,19 +36,30 @@ services:
|
||||||
# - OIDC_CLIENT_SECRET=
|
# - OIDC_CLIENT_SECRET=
|
||||||
# - OIDC_SCOPES=openid email profile
|
# - OIDC_SCOPES=openid email profile
|
||||||
# - OIDC_ADMIN_ROLES=admin
|
# - OIDC_ADMIN_ROLES=admin
|
||||||
|
# - OIDC_EMAIL_ATTRIBUTE=email
|
||||||
|
# - OIDC_NAME_ATTRIBUTE=name
|
||||||
|
# - OIDC_USERNAME_ATTRIBUTE=preferred_username
|
||||||
# - OIDC_ROLES_ATTRIBUTE=groups
|
# - OIDC_ROLES_ATTRIBUTE=groups
|
||||||
|
# - OIDC_IGNORE_USERNAME=true
|
||||||
# - OIDC_IGNORE_ROLES=true
|
# - OIDC_IGNORE_ROLES=true
|
||||||
|
# - OIDC_ENFORCED=true
|
||||||
depends_on:
|
depends_on:
|
||||||
- postgres
|
postgres:
|
||||||
|
condition: service_healthy
|
||||||
|
|
||||||
postgres:
|
postgres:
|
||||||
image: postgres:14-alpine
|
image: postgres:14-alpine
|
||||||
restart: unless-stopped
|
restart: on-failure
|
||||||
volumes:
|
volumes:
|
||||||
- db-data:/var/lib/postgresql/data
|
- db-data:/var/lib/postgresql/data
|
||||||
environment:
|
environment:
|
||||||
- POSTGRES_DB=planka
|
- POSTGRES_DB=planka
|
||||||
- POSTGRES_HOST_AUTH_METHOD=trust
|
- POSTGRES_HOST_AUTH_METHOD=trust
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD-SHELL", "pg_isready -U postgres -d planka"]
|
||||||
|
interval: 10s
|
||||||
|
timeout: 5s
|
||||||
|
retries: 5
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
user-avatars:
|
user-avatars:
|
||||||
|
|
|
@ -3,15 +3,7 @@ version: '3'
|
||||||
services:
|
services:
|
||||||
planka:
|
planka:
|
||||||
image: ghcr.io/plankanban/planka:latest
|
image: ghcr.io/plankanban/planka:latest
|
||||||
command: >
|
restart: on-failure
|
||||||
bash -c
|
|
||||||
"for i in `seq 1 30`; do
|
|
||||||
./start.sh &&
|
|
||||||
s=$$? && break || s=$$?;
|
|
||||||
echo \"Tried $$i times. Waiting 5 seconds...\";
|
|
||||||
sleep 5;
|
|
||||||
done; (exit $$s)"
|
|
||||||
restart: unless-stopped
|
|
||||||
volumes:
|
volumes:
|
||||||
- user-avatars:/app/public/user-avatars
|
- user-avatars:/app/public/user-avatars
|
||||||
- project-background-images:/app/public/project-background-images
|
- project-background-images:/app/public/project-background-images
|
||||||
|
@ -52,16 +44,22 @@ services:
|
||||||
# - OIDC_IGNORE_ROLES=true
|
# - OIDC_IGNORE_ROLES=true
|
||||||
# - OIDC_ENFORCED=true
|
# - OIDC_ENFORCED=true
|
||||||
depends_on:
|
depends_on:
|
||||||
- postgres
|
postgres:
|
||||||
|
condition: service_healthy
|
||||||
|
|
||||||
postgres:
|
postgres:
|
||||||
image: postgres:14-alpine
|
image: postgres:14-alpine
|
||||||
restart: unless-stopped
|
restart: on-failure
|
||||||
volumes:
|
volumes:
|
||||||
- db-data:/var/lib/postgresql/data
|
- db-data:/var/lib/postgresql/data
|
||||||
environment:
|
environment:
|
||||||
- POSTGRES_DB=planka
|
- POSTGRES_DB=planka
|
||||||
- POSTGRES_HOST_AUTH_METHOD=trust
|
- POSTGRES_HOST_AUTH_METHOD=trust
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD-SHELL", "pg_isready -U postgres -d planka"]
|
||||||
|
interval: 10s
|
||||||
|
timeout: 5s
|
||||||
|
retries: 5
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
user-avatars:
|
user-avatars:
|
||||||
|
|
23
healthcheck.js
Normal file
23
healthcheck.js
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
const http = require('http');
|
||||||
|
const options = {
|
||||||
|
host: 'localhost',
|
||||||
|
port: 1337,
|
||||||
|
timeout: 2000
|
||||||
|
};
|
||||||
|
|
||||||
|
const healthCheck = http.request(options, (res) => {
|
||||||
|
console.log(`HEALTHCHECK STATUS: ${res.statusCode}`);
|
||||||
|
if (res.statusCode == 200) {
|
||||||
|
process.exit(0);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
healthCheck.on('error', function (err) {
|
||||||
|
console.error('ERROR');
|
||||||
|
process.exit(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
healthCheck.end();
|
Loading…
Add table
Add a link
Reference in a new issue