mirror of
https://github.com/Hessenuk/DiscordTickets.git
synced 2025-01-21 14:56:27 +02:00
feat(docker): add non-root user, labels, and healthcheck (closes #433)
Now works with Pterodactyl.
This commit is contained in:
parent
faddacc6df
commit
bd42781878
@ -1,6 +1,8 @@
|
|||||||
root = true
|
root = true
|
||||||
|
|
||||||
[*]
|
[*]
|
||||||
|
indent_style = tab
|
||||||
|
indent_size = 4
|
||||||
end_of_line = lf
|
end_of_line = lf
|
||||||
insert_final_newline = true
|
insert_final_newline = true
|
||||||
trim_trailing_whitespace = true
|
trim_trailing_whitespace = true
|
||||||
|
17
Dockerfile
17
Dockerfile
@ -14,10 +14,19 @@ RUN CI=true pnpm install --prod --frozen-lockfile
|
|||||||
COPY --link . .
|
COPY --link . .
|
||||||
|
|
||||||
FROM node:18-alpine AS runner
|
FROM node:18-alpine AS runner
|
||||||
ENV NODE_ENV=production \
|
RUN adduser --disabled-password --home /home/container container
|
||||||
|
USER container
|
||||||
|
ENV USER=container \
|
||||||
|
HOME=/home/container \
|
||||||
|
NODE_ENV=production \
|
||||||
HTTP_HOST=0.0.0.0 \
|
HTTP_HOST=0.0.0.0 \
|
||||||
HTTP_PORT=80
|
HTTP_PORT=80
|
||||||
WORKDIR /usr/bot
|
WORKDIR /home/container
|
||||||
COPY --from=builder /build ./
|
COPY --from=builder /build ./
|
||||||
EXPOSE ${HTTP_PORT}
|
EXPOSE ${HTTP_PORT}/tcp
|
||||||
ENTRYPOINT [ "/usr/bot/scripts/start.sh" ]
|
ENTRYPOINT [ "/home/container/scripts/start.sh" ]
|
||||||
|
HEALTHCHECK --interval=15s --timeout=5s --start-period=60s \
|
||||||
|
CMD curl -f http://localhost:${HTTP_PORT}/status || exit 1
|
||||||
|
LABEL org.opencontainers.image.source=https://github.com/discord-tickets/bot \
|
||||||
|
org.opencontainers.image.description="The most popular open-source ticket bot for Discord." \
|
||||||
|
org.opencontainers.image.licenses="GPL-3.0-or-later"
|
||||||
|
@ -36,7 +36,7 @@
|
|||||||
"bot"
|
"bot"
|
||||||
],
|
],
|
||||||
"author": "eartharoid",
|
"author": "eartharoid",
|
||||||
"license": "GPL-3.0",
|
"license": "GPL-3.0-or-later",
|
||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://github.com/discord-tickets/bot/issues"
|
"url": "https://github.com/discord-tickets/bot/issues"
|
||||||
},
|
},
|
||||||
|
@ -122,7 +122,11 @@ module.exports = async client => {
|
|||||||
: responseTime >= 10
|
: responseTime >= 10
|
||||||
? '&e'
|
? '&e'
|
||||||
: '&a') + responseTime + 'ms';
|
: '&a') + responseTime + 'ms';
|
||||||
const level = req.routerPath === '/*' ? 'verbose' : 'info';
|
const level = req.routerPath === '/status'
|
||||||
|
? 'debug'
|
||||||
|
: req.routerPath === '/*'
|
||||||
|
? 'verbose'
|
||||||
|
: 'info';
|
||||||
client.log[level].http(short(`${req.id} ${req.ip} ${req.method} ${req.routerPath ?? '*'} &m-+>&r ${status}&b in ${responseTime}`));
|
client.log[level].http(short(`${req.id} ${req.ip} ${req.method} ${req.routerPath ?? '*'} &m-+>&r ${status}&b in ${responseTime}`));
|
||||||
if (!req.routerPath) client.log.verbose.http(`${req.id} ${req.method} ${req.url}`);
|
if (!req.routerPath) client.log.verbose.http(`${req.id} ${req.method} ${req.url}`);
|
||||||
done();
|
done();
|
||||||
|
6
src/routes/status.js
Normal file
6
src/routes/status.js
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
module.exports.get = () => ({
|
||||||
|
handler: async (req, res) => {
|
||||||
|
const { status } = res.context.config.client.ws;
|
||||||
|
res.code(status === 0 ? 200 : 425).send(status);
|
||||||
|
},
|
||||||
|
});
|
Loading…
Reference in New Issue
Block a user