Make SITE_URL and AUTH_SECRET configurable via environment variables for any deployment
This commit is contained in:
9
.env.example
Normal file
9
.env.example
Normal file
@@ -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
|
||||||
10
Dockerfile
10
Dockerfile
@@ -14,13 +14,21 @@ COPY . .
|
|||||||
# Create data directory for SQLite database
|
# Create data directory for SQLite database
|
||||||
RUN mkdir -p /app/data
|
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
|
# Build the application
|
||||||
RUN npm run build
|
RUN npm run build
|
||||||
|
|
||||||
# Expose port
|
# Expose port
|
||||||
EXPOSE 3000
|
EXPOSE 3000
|
||||||
|
|
||||||
# Set environment variables
|
# Set runtime environment variables
|
||||||
ENV NODE_ENV=production
|
ENV NODE_ENV=production
|
||||||
ENV NUXT_HOST=0.0.0.0
|
ENV NUXT_HOST=0.0.0.0
|
||||||
ENV NUXT_PORT=3000
|
ENV NUXT_PORT=3000
|
||||||
|
|||||||
55
README.md
55
README.md
@@ -21,6 +21,31 @@ A web application for managing and displaying weekly sermons for New Life Christ
|
|||||||
- **QR Codes**: qrcode library
|
- **QR Codes**: qrcode library
|
||||||
- **Deployment**: Docker & Docker Compose
|
- **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
|
## Getting Started
|
||||||
|
|
||||||
### Prerequisites
|
### Prerequisites
|
||||||
@@ -35,19 +60,29 @@ git clone <repository-url>
|
|||||||
cd nlcc-itinerary
|
cd nlcc-itinerary
|
||||||
```
|
```
|
||||||
|
|
||||||
2. Update environment variables in `docker-compose.yml`:
|
2. Create a `.env` file from the example:
|
||||||
```yaml
|
|
||||||
environment:
|
|
||||||
- AUTH_SECRET=your-secret-key-change-in-production
|
|
||||||
- SITE_URL=https://newlife-christian.com
|
|
||||||
```
|
|
||||||
|
|
||||||
3. Build and run with Docker Compose:
|
|
||||||
```bash
|
```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
|
### Default Credentials
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,10 @@
|
|||||||
services:
|
services:
|
||||||
nlcc-itinerary:
|
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
|
container_name: nlcc-itinerary
|
||||||
ports:
|
ports:
|
||||||
- "3002:3000"
|
- "3002:3000"
|
||||||
@@ -8,6 +12,6 @@ services:
|
|||||||
- ./data:/app/data
|
- ./data:/app/data
|
||||||
environment:
|
environment:
|
||||||
- NODE_ENV=production
|
- NODE_ENV=production
|
||||||
- AUTH_SECRET=d8c7c1735fc853b807c1bccce791b054
|
- AUTH_SECRET=${AUTH_SECRET:-change-this-secret-in-production}
|
||||||
- SITE_URL=https://nlcc.rydertech.us
|
- SITE_URL=${SITE_URL:-https://nlcc.rydertech.us}
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
|||||||
Reference in New Issue
Block a user