Add Portainer stack.env support for environment variable management

- Add docker/stack.env template for Portainer deployment
- Update Dockerfile to accept build args for Next.js environment variables
- Update docker-compose.deploy.yml to pass build args from environment
- Add comprehensive Portainer deployment guide in DOCKER_DEPLOYMENT.md
- Document environment variable setup for both CLI and Portainer deployments
This commit is contained in:
Arnaud
2026-07-01 11:25:42 +02:00
parent 9e7b83a12c
commit 163e1c6137
4 changed files with 154 additions and 7 deletions
+71 -2
View File
@@ -26,6 +26,8 @@ MinIO console: `http://localhost:9001` (minioadmin / minioadmin)
## Production Deployment
## Production Deployment
### 1. Prepare Environment
Copy and configure the production environment file:
@@ -34,7 +36,13 @@ Copy and configure the production environment file:
cp docker/.env.production .env.production
```
Edit `.env.production` and set:
Or for Portainer deployment, copy the stack environment file:
```bash
cp docker/stack.env stack.env.local
```
Edit the file and set:
- `POSTGRES_PASSWORD` - Strong random password
- `REDIS_PASSWORD` - Strong random password
- `MINIO_ROOT_PASSWORD` - Strong random password
@@ -44,6 +52,7 @@ Edit `.env.production` and set:
- `GOOGLE_CLIENT_ID` / `GOOGLE_CLIENT_SECRET` - OAuth credentials
- `OPENROUTER_API_KEY` - AI provider key
- `SMTP_*` - Email configuration
- `NEXT_PUBLIC_VAPID_PUBLIC_KEY` / `VAPID_PRIVATE_KEY` - Push notification keys
### 2. Build Docker Image
@@ -59,7 +68,67 @@ Or let Docker Compose build it automatically.
docker compose -f docker/docker-compose.deploy.yml --env-file .env.production up -d
```
### 4. Verify Deployment
## Portainer Deployment
Portainer provides a web UI for managing Docker containers and deploying stacks easily.
### Portainer Setup
1. **Prepare Environment File**
Copy the stack environment template:
```bash
cp docker/stack.env stack.env.local
```
Edit `stack.env.local` with your production values.
2. **Access Portainer**
Open your Portainer instance (typically `https://portainer.your-domain.com`).
3. **Deploy Stack**
- Go to **Stacks** → **Add Stack**
- Choose **Docker Compose** mode
- Select **Upload** to upload the compose file, or use **Editor** to paste the contents of `docker/docker-compose.deploy.yml`
- Copy the contents of `docker/stack.env` into the **Environment variables** section
- Click **Deploy the stack**
**Alternative: Using Environment File UI**
- In the stack creation form, there's an "Environment file" option
- You can paste the entire `stack.env` content there
- Portainer will parse and use all variables
4. **Verify Deployment**
- Check the **Containers** tab to see all services running
- View logs by clicking on each container
- Verify the app is accessible at `https://your-domain.com`
### Portainer Stack Update
To update the application after code changes:
1. Build new Docker image locally:
```bash
docker build -f Dockerfile -t epicure-web:latest .
docker push your-registry/epicure-web:latest
```
2. In Portainer:
- Go to your stack
- Click **Editor**
- Update the image reference if needed
- Click **Update the stack**
### Portainer Secrets (Optional)
For better security, use Portainer Secrets instead of environment variables:
1. Create a secret in Portainer with sensitive values
2. Reference it in the compose file: `${POSTGRES_PASSWORD}`
3. Portainer will inject the secret value during deployment
```bash
# Check all services are running