diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..c62e493 --- /dev/null +++ b/.env.example @@ -0,0 +1,9 @@ +# Site Configuration +# The public URL where your application will be hosted +# This is used for QR codes and other absolute URLs +SITE_URL=https://your-domain.com + +# Authentication Secret +# Generate a secure random string for production +# You can use: openssl rand -hex 32 +AUTH_SECRET=change-this-secret-in-production diff --git a/Dockerfile b/Dockerfile index cb05e5e..b190299 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,13 +14,21 @@ COPY . . # Create data directory for SQLite database RUN mkdir -p /app/data +# Accept build arguments +ARG SITE_URL=https://nlcc.rydertech.us +ARG AUTH_SECRET + +# Set environment variables for build +ENV SITE_URL=$SITE_URL +ENV AUTH_SECRET=$AUTH_SECRET + # Build the application RUN npm run build # Expose port EXPOSE 3000 -# Set environment variables +# Set runtime environment variables ENV NODE_ENV=production ENV NUXT_HOST=0.0.0.0 ENV NUXT_PORT=3000 diff --git a/README.md b/README.md index 262265a..2c6cfc5 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,31 @@ A web application for managing and displaying weekly sermons for New Life Christ - **QR Codes**: qrcode library - **Deployment**: Docker & Docker Compose +## Configuration + +This application uses environment variables for configuration. These must be set before building the Docker image. + +### Environment Variables + +| Variable | Description | Required | Default | +|----------|-------------|----------|---------| +| `SITE_URL` | Public URL where the app is hosted (used for QR codes) | Yes | `https://nlcc.rydertech.us` | +| `AUTH_SECRET` | Secret key for authentication sessions | Yes | `change-this-secret-in-production` | + +### Setting Up Environment Variables + +Create a `.env` file in the project root: + +```bash +SITE_URL=https://your-church-domain.com +AUTH_SECRET=your-secure-random-secret-here +``` + +**Generate a secure AUTH_SECRET:** +```bash +openssl rand -hex 32 +``` + ## Getting Started ### Prerequisites @@ -35,19 +60,29 @@ git clone cd nlcc-itinerary ``` -2. Update environment variables in `docker-compose.yml`: -```yaml -environment: - - AUTH_SECRET=your-secret-key-change-in-production - - SITE_URL=https://newlife-christian.com -``` - -3. Build and run with Docker Compose: +2. Create a `.env` file from the example: ```bash -docker-compose up -d +cp .env.example .env ``` -The application will be available at `http://localhost:3000` +3. Edit `.env` and configure your settings: +```bash +# Required: Set your public URL (used for QR codes) +SITE_URL=https://your-domain.com + +# Required: Set a secure authentication secret +# Generate with: openssl rand -hex 32 +AUTH_SECRET=your-secure-random-secret-here +``` + +4. Build and run with Docker Compose: +```bash +docker-compose up -d --build +``` + +The application will be available at `http://localhost:3002` (or your configured port) + +**Important**: The `SITE_URL` must be set correctly for QR codes to work. This should be the public URL where your application is accessible (e.g., `https://church.example.com`). ### Default Credentials diff --git a/docker-compose.yml b/docker-compose.yml index de8a7ed..108ae37 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,6 +1,10 @@ services: nlcc-itinerary: - build: . + build: + context: . + args: + - SITE_URL=${SITE_URL:-https://nlcc.rydertech.us} + - AUTH_SECRET=${AUTH_SECRET:-change-this-secret-in-production} container_name: nlcc-itinerary ports: - "3002:3000" @@ -8,6 +12,6 @@ services: - ./data:/app/data environment: - NODE_ENV=production - - AUTH_SECRET=d8c7c1735fc853b807c1bccce791b054 - - SITE_URL=https://nlcc.rydertech.us + - AUTH_SECRET=${AUTH_SECRET:-change-this-secret-in-production} + - SITE_URL=${SITE_URL:-https://nlcc.rydertech.us} restart: unless-stopped