3 Dockerfile
dougbeatty edited this page 2026-05-25 13:44:18 +00:00

Docker Setup

This page documents a simple Docker-based setup for running printmechecks in development and production.

Overview

  • Use the docker-compose.yml below for local development with hot reload on port 5173.
  • Use the Dockerfile below to build a production image that serves the built app with Nginx on port 80.
  • If the app lives at the repository root rather than in a printmechecks/ subfolder, update the COPY paths in the Dockerfile accordingly.

Development with Docker Compose

Use this for local development:

version: '3.8'

services:
  printmechecks:
    image: node:18-alpine
    container_name: printmechecks
    working_dir: /app
    volumes:
      - ./printmechecks:/app
    ports:
      - "5173:5173"
    command: sh -c "npm install && npm run dev -- --host 0.0.0.0"
    restart: unless-stopped
    environment:
      - NODE_ENV=development

Run it

docker compose up --build

Then open:

http://localhost:5173

Production Dockerfile

Use this to build a production image:

# Build stage
FROM node:18-alpine as build

WORKDIR /app

# Copy package files
COPY printmechecks/package*.json ./

# Install dependencies
RUN npm ci

# Copy source code
COPY printmechecks/ ./

# Build the application
RUN npm run build

# Production stage
FROM nginx:alpine

# Copy built assets from build stage
COPY --from=build /app/dist /usr/share/nginx/html

# Copy nginx configuration (optional - using default)
# COPY nginx.conf /etc/nginx/conf.d/default.conf

# Expose port 80
EXPOSE 80

# Start nginx
CMD ["nginx", "-g", "daemon off;"]

Build and run

docker build -t printmechecks .
docker run -d --name printmechecks -p 8080:80 printmechecks

Then open:

http://localhost:8080

Notes

  • The compose file is a development workflow and does not use the production Dockerfile.
  • The production image assumes the app builds into a dist/ directory.
  • If the repository root is already the app root, change these lines in the Dockerfile:
COPY package*.json ./
COPY . ./

Uploading to the Forgejo wiki API

  1. Base64-encode this markdown file on macOS:
base64 -i docker-setup.md
  1. Use the encoded output in the API request:
curl -X POST \
  'https://git.dougbeatty.com/api/v1/repos/dougbeatty/printmechecks/wiki/new' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: token YOUR_TOKEN_HERE' \
  -d '{
    "content_base64": "PASTE_BASE64_HERE",
    "message": "Add Docker setup wiki page",
    "title": "Docker Setup"
  }'

If the page already exists and you want to update it, use the corresponding wiki edit endpoint in the Forgejo API UI.