Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# PostgreSQL Configuration
POSTGRES_USER=temporal
POSTGRES_PASSWORD=temporal
POSTGRES_DB=temporal
POSTGRES_PORT=5432

# n8n Configuration
N8N_WEBHOOK_URL=http://localhost:5678/
N8N_ENCRYPTION_KEY=a_random_string_for_encryption
N8N_PORT=5678

# OpenSearch Configuration
DISABLE_SECURITY_PLUGIN=true
OPENSEARCH_PORT=9200

# Temporal Configuration
TEMPORAL_PORT=7233
TEMPORAL_UI_PORT=8080

# Volumes path (you can customize if needed)
PWD=.
43 changes: 39 additions & 4 deletions .github/workflows/code-quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,54 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Checkout
- name: Checkout code
uses: actions/checkout@v4
- name: Lint
- name: Run linting
run: echo "Linting..."

sonarqube:
name: SonarQube
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: SonarQube Scan
- name: Run SonarQube scan
uses: SonarSource/sonarqube-scan-action@v5
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

hadolint:
name: Dockerfile Linting
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Lint Dockerfile.n8n
run: docker run --rm -i hadolint/hadolint < Dockerfile.n8n
- name: Lint Dockerfile.temporal
run: docker run --rm -i hadolint/hadolint < Dockerfile.temporal

service-check:
name: Service Availability Check
timeout-minutes: 10
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Create volume directories
run: bash scripts/setup_volumes.sh
- name: Copy .env file
run: cp .env.example .env
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build services with no cache
run: docker compose build --no-cache
- name: Start services
run: docker compose up -d
- name: Verify services
run: bash scripts/check_services.sh
- name: Stop services
if: always()
run: docker compose down -v
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*

# mcp executable
mcp
mcp-config.json
.cursor/

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

Expand Down Expand Up @@ -134,3 +139,4 @@ dist
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*
volumes
20 changes: 20 additions & 0 deletions Dockerfile.n8n
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM n8nio/n8n:1.89.2

# Define build arguments
ARG NODE_ENV=production
ARG N8N_PORT=5678
# Environment variables are now defined in docker-compose.yml

# Create app directory
WORKDIR /home/node

# Add custom healthcheck using exec form
HEALTHCHECK --interval=30s --timeout=10s --retries=3 --start-period=30s \
CMD ["/bin/sh", "-c", "wget -q --spider http://0.0.0.0:${N8N_PORT}/healthz || exit 1"]

# Explicitly set the user to the non-root 'node' user (which is already set up in the base image)
USER node

EXPOSE ${N8N_PORT}
# The entrypoint script is already defined in the base image
# Don't override the CMD
20 changes: 20 additions & 0 deletions Dockerfile.temporal
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM temporalio/auto-setup:1.20.5

# Build arguments are still needed for the temporal container setup
# Keeping only those used in the HEALTHCHECK or other commands
ARG HOST=temporal
ARG TEMPORAL_PORT=7233

# Environment variables are now defined in docker-compose.yml

# Add custom healthcheck using exec form
HEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=3 \
CMD ["/bin/sh", "-c", "temporal operator cluster health --address ${HOST}:${TEMPORAL_PORT} | grep -q SERVING || exit 1"]

# Explicitly set the user to the non-root 'temporal' user (already defined in the base image)
USER temporal

# Expose the gRPC port
EXPOSE ${TEMPORAL_PORT}

# The entrypoint script is already defined in the base image
174 changes: 173 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,173 @@
# automatization
# n8n and Temporal Docker Compose Setup

This repository contains a Docker Compose configuration to run n8n and Temporal services together.

## Services

The setup includes:

- **n8n**: An automation tool that allows you to create workflows visually
- **Temporal**: A workflow orchestration platform with the following components:
- Temporal server
- Temporal UI
- PostgreSQL (database)
- OpenSearch (for visibility features)

## Custom Docker Images

This project uses custom Docker images built from the following Dockerfiles:

- **Dockerfile.n8n**: Extends the official n8n image with custom configurations
- **Dockerfile.temporal**: Extends the official Temporal auto-setup image

## Usage

### Prepare volume directories

Before starting the services, run the setup script to create the necessary volume directories:

```bash
./scripts/setup_volumes.sh
```

This prevents volume mount errors that may occur if the directories don't exist.

### Create environment file

Create a `.env` file in the root directory of the project with your environment variables:

```bash
cp .env.example .env
```

Then edit the `.env` file to set your specific configuration values.

### Starting the services

```bash
docker compose up -d
```

This will start all services in detached mode.

### Building custom images

Rebuild images after modifying the Dockerfiles:

```bash
docker compose build
```

Or to rebuild and start in one command:

```bash
docker compose down && docker compose build && docker compose up -d
```

### Verifying services are running

Check that all containers are running:

```bash
docker compose ps
```

You should see containers for:
- n8n
- temporal
- temporal-ui
- temporal-postgresql
- opensearch

### Checking Service Health

Use the provided script to verify that all services are accessible:

```bash
scripts/check_services.sh
```

This will check:
- n8n health endpoint
- Temporal UI web interface
- OpenSearch API
- Temporal server gRPC port
- PostgreSQL database connection

Example output:
```text
Checking service availability...
Checking n8n at http://localhost:5678/healthz... ACCESSIBLE ✅ (HTTP 200)
Checking temporal-ui at http://localhost:8080... ACCESSIBLE ✅ (HTTP 200)
Checking opensearch at http://localhost:9200... ACCESSIBLE ✅ (HTTP 200)
Checking temporal at localhost:7233... ACCESSIBLE ✅
Checking postgresql at localhost:5432... ACCESSIBLE ✅

Service URLs:
- n8n: http://localhost:5678
- Temporal UI: http://localhost:8080
- OpenSearch: http://localhost:9200
```

### Accessing the services

- **n8n**: <http://localhost:5678>
- **Temporal UI**: <http://localhost:8080>

You can verify the services are responding with:

```bash
# Check n8n is responding
curl -I http://localhost:5678

# Check Temporal UI is responding
curl -I http://localhost:8080
```

### Stopping the services

```bash
docker compose down
```

To completely remove all data volumes:

```bash
docker compose down -v
```

## Data Persistence

All data is stored in local volumes under the `./volumes/` directory:

- `./volumes/n8n_data` - n8n data and workflows
- `./volumes/opensearch-data` - OpenSearch data for Temporal
- `./volumes/postgresql-data` - PostgreSQL database for Temporal

## Service Ports

- n8n: 5678
- Temporal server: 7233 (gRPC API, not HTTP)
- Temporal UI: 8080
- PostgreSQL: 5432
- OpenSearch: 9200

## Troubleshooting

If you encounter any issues:

1. Check container logs:
```bash
docker logs temporal
docker logs automatization-n8n-1
```

2. Ensure all required ports are available on your system

3. Make sure Docker has sufficient resources allocated

4. If you encounter volume mount errors (e.g., "failed to mount local volume ... no such file or directory"), run the setup script:
```bash
./scripts/setup_volumes.sh
```
This creates the necessary volume directories in the `./volumes/` folder.
Loading