Skip to content

Commit 0a75a77

Browse files
authored
Add Docker setup and CI pipeline for n8n and Temporal workflow automa… (#4)
…tion with documentation. - Added GitHub Actions workflow with Dockerfile linting - Created Dockerfiles for n8n and Temporal services - Added docker-compose.yml for orchestration - Updated .gitignore to exclude volumes - Enhanced README with setup instructions
1 parent 389a18f commit 0a75a77

File tree

9 files changed

+507
-5
lines changed

9 files changed

+507
-5
lines changed

.env.example

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# PostgreSQL Configuration
2+
POSTGRES_USER=temporal
3+
POSTGRES_PASSWORD=temporal
4+
POSTGRES_DB=temporal
5+
POSTGRES_PORT=5432
6+
7+
# n8n Configuration
8+
N8N_WEBHOOK_URL=http://localhost:5678/
9+
N8N_ENCRYPTION_KEY=a_random_string_for_encryption
10+
N8N_PORT=5678
11+
12+
# OpenSearch Configuration
13+
DISABLE_SECURITY_PLUGIN=true
14+
OPENSEARCH_PORT=9200
15+
16+
# Temporal Configuration
17+
TEMPORAL_PORT=7233
18+
TEMPORAL_UI_PORT=8080
19+
20+
# Volumes path (you can customize if needed)
21+
PWD=.

.github/workflows/code-quality.yml

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,54 @@ jobs:
1212
runs-on: ubuntu-latest
1313

1414
steps:
15-
- name: Checkout
15+
- name: Checkout code
1616
uses: actions/checkout@v4
17-
- name: Lint
17+
- name: Run linting
1818
run: echo "Linting..."
1919

2020
sonarqube:
2121
name: SonarQube
2222
runs-on: ubuntu-latest
2323
steps:
24-
- uses: actions/checkout@v4
24+
- name: Checkout code
25+
uses: actions/checkout@v4
2526
with:
2627
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
27-
- name: SonarQube Scan
28+
- name: Run SonarQube scan
2829
uses: SonarSource/sonarqube-scan-action@v5
2930
env:
3031
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
32+
33+
hadolint:
34+
name: Dockerfile Linting
35+
runs-on: ubuntu-latest
36+
steps:
37+
- name: Checkout code
38+
uses: actions/checkout@v4
39+
- name: Lint Dockerfile.n8n
40+
run: docker run --rm -i hadolint/hadolint < Dockerfile.n8n
41+
- name: Lint Dockerfile.temporal
42+
run: docker run --rm -i hadolint/hadolint < Dockerfile.temporal
43+
44+
service-check:
45+
name: Service Availability Check
46+
timeout-minutes: 10
47+
runs-on: ubuntu-latest
48+
steps:
49+
- name: Checkout code
50+
uses: actions/checkout@v4
51+
- name: Create volume directories
52+
run: bash scripts/setup_volumes.sh
53+
- name: Copy .env file
54+
run: cp .env.example .env
55+
- name: Set up Docker Buildx
56+
uses: docker/setup-buildx-action@v3
57+
- name: Build services with no cache
58+
run: docker compose build --no-cache
59+
- name: Start services
60+
run: docker compose up -d
61+
- name: Verify services
62+
run: bash scripts/check_services.sh
63+
- name: Stop services
64+
if: always()
65+
run: docker compose down -v

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ yarn-error.log*
77
lerna-debug.log*
88
.pnpm-debug.log*
99

10+
# mcp executable
11+
mcp
12+
mcp-config.json
13+
.cursor/
14+
1015
# Diagnostic reports (https://nodejs.org/api/report.html)
1116
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
1217

@@ -134,3 +139,4 @@ dist
134139
.yarn/build-state.yml
135140
.yarn/install-state.gz
136141
.pnp.*
142+
volumes

Dockerfile.n8n

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
FROM n8nio/n8n:1.89.2
2+
3+
# Define build arguments
4+
ARG NODE_ENV=production
5+
ARG N8N_PORT=5678
6+
# Environment variables are now defined in docker-compose.yml
7+
8+
# Create app directory
9+
WORKDIR /home/node
10+
11+
# Add custom healthcheck using exec form
12+
HEALTHCHECK --interval=30s --timeout=10s --retries=3 --start-period=30s \
13+
CMD ["/bin/sh", "-c", "wget -q --spider http://0.0.0.0:${N8N_PORT}/healthz || exit 1"]
14+
15+
# Explicitly set the user to the non-root 'node' user (which is already set up in the base image)
16+
USER node
17+
18+
EXPOSE ${N8N_PORT}
19+
# The entrypoint script is already defined in the base image
20+
# Don't override the CMD

Dockerfile.temporal

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
FROM temporalio/auto-setup:1.20.5
2+
3+
# Build arguments are still needed for the temporal container setup
4+
# Keeping only those used in the HEALTHCHECK or other commands
5+
ARG HOST=temporal
6+
ARG TEMPORAL_PORT=7233
7+
8+
# Environment variables are now defined in docker-compose.yml
9+
10+
# Add custom healthcheck using exec form
11+
HEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=3 \
12+
CMD ["/bin/sh", "-c", "temporal operator cluster health --address ${HOST}:${TEMPORAL_PORT} | grep -q SERVING || exit 1"]
13+
14+
# Explicitly set the user to the non-root 'temporal' user (already defined in the base image)
15+
USER temporal
16+
17+
# Expose the gRPC port
18+
EXPOSE ${TEMPORAL_PORT}
19+
20+
# The entrypoint script is already defined in the base image

README.md

Lines changed: 173 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,173 @@
1-
# automatization
1+
# n8n and Temporal Docker Compose Setup
2+
3+
This repository contains a Docker Compose configuration to run n8n and Temporal services together.
4+
5+
## Services
6+
7+
The setup includes:
8+
9+
- **n8n**: An automation tool that allows you to create workflows visually
10+
- **Temporal**: A workflow orchestration platform with the following components:
11+
- Temporal server
12+
- Temporal UI
13+
- PostgreSQL (database)
14+
- OpenSearch (for visibility features)
15+
16+
## Custom Docker Images
17+
18+
This project uses custom Docker images built from the following Dockerfiles:
19+
20+
- **Dockerfile.n8n**: Extends the official n8n image with custom configurations
21+
- **Dockerfile.temporal**: Extends the official Temporal auto-setup image
22+
23+
## Usage
24+
25+
### Prepare volume directories
26+
27+
Before starting the services, run the setup script to create the necessary volume directories:
28+
29+
```bash
30+
./scripts/setup_volumes.sh
31+
```
32+
33+
This prevents volume mount errors that may occur if the directories don't exist.
34+
35+
### Create environment file
36+
37+
Create a `.env` file in the root directory of the project with your environment variables:
38+
39+
```bash
40+
cp .env.example .env
41+
```
42+
43+
Then edit the `.env` file to set your specific configuration values.
44+
45+
### Starting the services
46+
47+
```bash
48+
docker compose up -d
49+
```
50+
51+
This will start all services in detached mode.
52+
53+
### Building custom images
54+
55+
Rebuild images after modifying the Dockerfiles:
56+
57+
```bash
58+
docker compose build
59+
```
60+
61+
Or to rebuild and start in one command:
62+
63+
```bash
64+
docker compose down && docker compose build && docker compose up -d
65+
```
66+
67+
### Verifying services are running
68+
69+
Check that all containers are running:
70+
71+
```bash
72+
docker compose ps
73+
```
74+
75+
You should see containers for:
76+
- n8n
77+
- temporal
78+
- temporal-ui
79+
- temporal-postgresql
80+
- opensearch
81+
82+
### Checking Service Health
83+
84+
Use the provided script to verify that all services are accessible:
85+
86+
```bash
87+
scripts/check_services.sh
88+
```
89+
90+
This will check:
91+
- n8n health endpoint
92+
- Temporal UI web interface
93+
- OpenSearch API
94+
- Temporal server gRPC port
95+
- PostgreSQL database connection
96+
97+
Example output:
98+
```text
99+
Checking service availability...
100+
Checking n8n at http://localhost:5678/healthz... ACCESSIBLE ✅ (HTTP 200)
101+
Checking temporal-ui at http://localhost:8080... ACCESSIBLE ✅ (HTTP 200)
102+
Checking opensearch at http://localhost:9200... ACCESSIBLE ✅ (HTTP 200)
103+
Checking temporal at localhost:7233... ACCESSIBLE ✅
104+
Checking postgresql at localhost:5432... ACCESSIBLE ✅
105+
106+
Service URLs:
107+
- n8n: http://localhost:5678
108+
- Temporal UI: http://localhost:8080
109+
- OpenSearch: http://localhost:9200
110+
```
111+
112+
### Accessing the services
113+
114+
- **n8n**: <http://localhost:5678>
115+
- **Temporal UI**: <http://localhost:8080>
116+
117+
You can verify the services are responding with:
118+
119+
```bash
120+
# Check n8n is responding
121+
curl -I http://localhost:5678
122+
123+
# Check Temporal UI is responding
124+
curl -I http://localhost:8080
125+
```
126+
127+
### Stopping the services
128+
129+
```bash
130+
docker compose down
131+
```
132+
133+
To completely remove all data volumes:
134+
135+
```bash
136+
docker compose down -v
137+
```
138+
139+
## Data Persistence
140+
141+
All data is stored in local volumes under the `./volumes/` directory:
142+
143+
- `./volumes/n8n_data` - n8n data and workflows
144+
- `./volumes/opensearch-data` - OpenSearch data for Temporal
145+
- `./volumes/postgresql-data` - PostgreSQL database for Temporal
146+
147+
## Service Ports
148+
149+
- n8n: 5678
150+
- Temporal server: 7233 (gRPC API, not HTTP)
151+
- Temporal UI: 8080
152+
- PostgreSQL: 5432
153+
- OpenSearch: 9200
154+
155+
## Troubleshooting
156+
157+
If you encounter any issues:
158+
159+
1. Check container logs:
160+
```bash
161+
docker logs temporal
162+
docker logs automatization-n8n-1
163+
```
164+
165+
2. Ensure all required ports are available on your system
166+
167+
3. Make sure Docker has sufficient resources allocated
168+
169+
4. If you encounter volume mount errors (e.g., "failed to mount local volume ... no such file or directory"), run the setup script:
170+
```bash
171+
./scripts/setup_volumes.sh
172+
```
173+
This creates the necessary volume directories in the `./volumes/` folder.

0 commit comments

Comments
 (0)