-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdocker-compose.yaml
More file actions
126 lines (109 loc) · 3.16 KB
/
docker-compose.yaml
File metadata and controls
126 lines (109 loc) · 3.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
---
# Butane Config for Flatcar Container Linux
# Example: Running Docker Compose stack as systemd service
variant: flatcar
version: 1.0.0
passwd:
users:
- name: core
ssh_authorized_keys:
- ssh-rsa AAAAB3... user@example.com # Replace with your SSH public key
storage:
files:
- path: /etc/hostname
mode: 0644
contents:
source: http://169.254.169.254/hetzner/v1/metadata/hostname
# Docker Compose file
- path: /opt/docker-compose.yml
mode: 0644
contents:
inline: |
version: '3.8'
services:
# Nginx web server
web:
image: nginx:alpine
ports:
- "80:80"
- "443:443"
volumes:
- ./html:/usr/share/nginx/html:ro
restart: always
# Redis cache
redis:
image: redis:alpine
ports:
- "6379:6379"
restart: always
# PostgreSQL database
db:
image: postgres:16-alpine
environment:
POSTGRES_PASSWORD: changeme
POSTGRES_USER: myapp
POSTGRES_DB: myapp
volumes:
- db-data:/var/lib/postgresql/data
restart: always
volumes:
db-data:
# Example application HTML
- path: /opt/html/index.html
mode: 0644
contents:
inline: |
<!DOCTYPE html>
<html>
<head>
<title>Flatcar on Hetzner Cloud</title>
</head>
<body>
<h1>Hello from Flatcar Container Linux!</h1>
<p>Running on Hetzner Cloud with Docker Compose</p>
</body>
</html>
systemd:
units:
# Enable Docker
- name: docker.service
enabled: true
# Docker Compose service
- name: docker-compose-app.service
enabled: true
contents: |
[Unit]
Description=Docker Compose Application
After=docker.service
Requires=docker.service
[Service]
Type=oneshot
RemainAfterExit=yes
WorkingDirectory=/opt
ExecStartPre=/usr/bin/docker-compose -f /opt/docker-compose.yml pull
ExecStart=/usr/bin/docker-compose -f /opt/docker-compose.yml up -d
ExecStop=/usr/bin/docker-compose -f /opt/docker-compose.yml down
[Install]
WantedBy=multi-user.target
# Docker Compose updater (pull and restart daily)
- name: docker-compose-updater.service
contents: |
[Unit]
Description=Update Docker Compose Stack
After=docker.service
Requires=docker.service
[Service]
Type=oneshot
WorkingDirectory=/opt
ExecStart=/usr/bin/docker-compose -f /opt/docker-compose.yml pull
ExecStart=/usr/bin/docker-compose -f /opt/docker-compose.yml up -d
- name: docker-compose-updater.timer
enabled: true
contents: |
[Unit]
Description=Update Docker Compose Stack daily
[Timer]
OnCalendar=daily
Persistent=true
[Install]
WantedBy=timers.target