KommtKevinOnline can be deployed using Docker for a consistent and isolated environment. The application uses a multi-stage build process to optimize the final image size.
Building and running with Docker
Build the Docker image
The Dockerfile uses a multi-stage build with Node.js LTS. Build the image with:docker build -t kommtkevinonline .
You can customize the port during build time:docker build --build-arg PORT=8080 -t kommtkevinonline .
Run the container
docker run -p 3000:3000 \
-e NUXT_APP_POSTGRES_URL="postgresql://user:password@host:5432/database" \
-e TWITCH_CLIENT_ID="your_client_id" \
-e TWITCH_CLIENT_SECRET="your_client_secret" \
kommtkevinonline
Using Docker Compose
The included docker-compose.yml provides a simple orchestration setup:services:
node:
build:
context: .
dockerfile: Dockerfile
ports:
- 3000:3000
volumes:
- .:/src
command: npm start
Run with Docker Compose:
The following environment variables are required for the application to function:
NUXT_APP_POSTGRES_URL - PostgreSQL connection string
TWITCH_CLIENT_ID - Twitch API client ID
TWITCH_CLIENT_SECRET - Twitch API client secret
See the Environment variables page for complete configuration details.
Port configuration
The application port can be configured in two ways:
- Build-time: Use the
PORT build argument when building the image
- Runtime: Set the
PORT environment variable when running the container
The default port is 3000.
Docker build process
The Dockerfile uses a two-stage build:
Build stage
FROM node:lts-slim AS build
RUN corepack enable
ARG PORT=3000
WORKDIR /src
COPY package.json pnpm-lock.yaml ./
RUN pnpm install
COPY --link . .
RUN pnpm run build
Runtime stage
FROM node:lts-slim
ENV PORT=$PORT
COPY --from=build /src/.output /src/.output
COPY --from=build /src/node_modules /src/node_modules
WORKDIR /src
CMD [ "node", ".output/server/index.mjs" ]
This approach ensures the final image only contains the built application and necessary dependencies, reducing image size.
For production deployments, consider using a .dockerignore file to exclude development files and reduce build context size.