DiscordTickets/Dockerfile

36 lines
1.3 KiB
Docker
Raw Permalink Normal View History

# syntax=docker/dockerfile:1
2023-02-15 03:16:04 +02:00
FROM node:18-alpine AS builder
WORKDIR /build
# install python etc so node-gyp works for the optional dependencies
2023-02-15 03:13:35 +02:00
RUN apk add --no-cache make gcc g++ python3
# install pnpm to make dependency installation faster (because it has a lockfile)
RUN npm install -g pnpm
COPY package.json pnpm-lock.yaml ./
COPY --link scripts scripts
RUN chmod +x ./scripts/start.sh
# install dependencies, CI=true to skip pre/postinstall scripts
RUN CI=true pnpm install --prod --frozen-lockfile
COPY --link . .
2023-02-15 03:16:04 +02:00
FROM node:18-alpine AS runner
RUN apk --no-cache add curl \
&& adduser --disabled-password --home /home/container container \
2024-01-12 02:42:17 +02:00
&& mkdir /app \
2024-01-12 02:46:13 +02:00
&& chown container:container /app \
2024-01-12 02:42:17 +02:00
&& chmod -R 777 /app
USER container
ENV USER=container \
HOME=/home/container \
NODE_ENV=production \
HTTP_HOST=0.0.0.0 \
DOCKER=true
WORKDIR /home/container
2024-01-12 02:52:25 +02:00
COPY --from=builder --chown=container:container --chmod=777 /build /app
ENTRYPOINT [ "/app/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"