Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 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
38 changes: 34 additions & 4 deletions .github/workflows/code-quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,49 @@ 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
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- 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
run: docker compose down
if: always()
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -134,3 +134,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.22.0

# Add custom environment variables
ENV N8N_PORT=5678 \
NODE_ENV=production \
N8N_METRICS=true \
N8N_HEALTH_CHECK_ENDPOINT=true

# Create app directory
WORKDIR /home/node/.n8n

# Add custom healthcheck - using shell form to ensure || works correctly
HEALTHCHECK --interval=30s --timeout=10s --retries=3 \
CMD /bin/sh -c "curl -s http://localhost:${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

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

# Set up environment variables for PostgreSQL and Elasticsearch
ENV DB=postgresql \
DB_PORT=5432 \
POSTGRES_USER=temporal \
POSTGRES_PWD=temporal \
POSTGRES_SEEDS=postgresql \
ENABLE_ES=true \
ES_SEEDS=elasticsearch \
ES_VERSION=v7

# Add custom healthcheck - using shell form to ensure || works correctly
HEALTHCHECK --interval=30s --timeout=10s --retries=3 \
CMD /bin/sh -c "temporal operator cluster health --address 0.0.0.0:7233 | 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 7233

# The entrypoint script is already defined in the base image
147 changes: 146 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,146 @@
# 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)
- Elasticsearch (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

### Starting the services

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

This will start all services in detached mode.

### Building custom images

If you've made changes to the Dockerfiles, you'll need to rebuild the images:

```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
- temporal-elasticsearch

### Checking Service Health

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

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

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

Example output:
```
Checking service availability...
Checking n8n at http://localhost:5678/healthz... ACCESSIBLE ✅ (HTTP 200)
Checking temporal-ui at http://localhost:8080... ACCESSIBLE ✅ (HTTP 200)
Checking elasticsearch 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
- Elasticsearch: 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/elasticsearch-data` - Elasticsearch 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
- Elasticsearch: 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
118 changes: 118 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
services:
# n8n service
n8n:
build:
context: .
dockerfile: Dockerfile.n8n
ports:
- "5678:5678"
environment:
- WEBHOOK_URL=http://localhost:5678/
volumes:
- n8n_data:/home/node/.n8n
networks:
- app-network
user: node

# Temporal services
elasticsearch:
container_name: temporal-elasticsearch
image: opensearchproject/opensearch:2.5.0
environment:
- discovery.type=single-node
- bootstrap.memory_lock=true
- "OPENSEARCH_JAVA_OPTS=-Xms256m -Xmx256m"
- "DISABLE_SECURITY_PLUGIN=true"
- "DISABLE_INSTALL_DEMO_CONFIG=true"
ports:
- 9200:9200
cap_add:
- IPC_LOCK
ulimits:
memlock:
soft: -1
hard: -1
volumes:
- elasticsearch-data:/usr/share/opensearch/data
networks:
- app-network
healthcheck:
test: ["CMD-SHELL", "curl -sSf http://localhost:9200/ || exit 1"]
interval: 30s
timeout: 10s
retries: 5

postgresql:
container_name: temporal-postgresql
image: postgres:14
environment:
POSTGRES_USER: temporal
POSTGRES_PASSWORD: temporal
POSTGRES_DB: temporal
ports:
- 5432:5432
volumes:
- postgresql-data:/var/lib/postgresql/data
networks:
- app-network
user: postgres
healthcheck:
test: ["CMD-SHELL", "pg_isready -U temporal"]
interval: 5s
timeout: 5s
retries: 5
start_period: 10s

temporal:
container_name: temporal
build:
context: .
dockerfile: Dockerfile.temporal
depends_on:
postgresql:
condition: service_healthy
elasticsearch:
condition: service_healthy
ports:
- 7233:7233
networks:
- app-network
user: temporal

temporal-ui:
container_name: temporal-ui
image: temporalio/ui:2.10.3
depends_on:
temporal:
condition: service_started
environment:
- TEMPORAL_ADDRESS=temporal:7233
- TEMPORAL_PERMIT_WRITE_API=true
ports:
- 8080:8080
networks:
- app-network

volumes:
n8n_data:
driver: local
driver_opts:
type: none
o: bind
device: ${PWD}/volumes/n8n_data
elasticsearch-data:
driver: local
driver_opts:
type: none
o: bind
device: ${PWD}/volumes/elasticsearch-data
postgresql-data:
driver: local
driver_opts:
type: none
o: bind
device: ${PWD}/volumes/postgresql-data

networks:
app-network:
driver: bridge
Loading
Loading