aboutsummaryrefslogtreecommitdiff
path: root/docker-compose.yml
blob: 34a32f3830300d58ca34cf96c4d191f481d349b5 (plain) (blame)
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
version: "3.0"

volumes:
  media:
  transmission-config:
  transmission-watch:
  nextcloud-config:
  nextcloud-data:
  nextcloud-www:
  caddy-config:
  caddy-data:
  vw-data:
  postgres-data:
  postgres-backups:

networks:
  inner:

services:
  minidlna:
    build:
      context: minidlna
      dockerfile: Dockerfile
    container_name: dlna
    environment:
      PUID: 1000
      PGID: 1000
      TZ: ${TZ}
      MINIDLNA_MEDIA_DIR: /media
      MINIDLNA_FRIENDLY_NAME: tinyNAS
    volumes:
      - media:/media
    healthcheck:
      test:
        [
          "CMD",
          "curl",
          "--silent",
          "--fail",
          "127.0.0.1:8200",
          "||",
          "exit 1"
        ]
      interval: 10s
      timeout: 10s
      retries: 6
      start_period: 10s
    restart: unless-stopped
    ports:
      - 8200:8200
  
  transmission:
    image: lscr.io/linuxserver/transmission:latest
    container_name: transmission
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=${TZ}
      - USER=${TRANSMISSION_USER}
      - PASS=${TRANSMISSION_PASSWORD}
    volumes:
      - transmission-config:/config
      - media:/downloads
      - transmission-watch:/watch
    ports:
      - 51413:51413
      - 51413:51413/udp
    restart: unless-stopped
    networks:
      - inner

  nextcloud:
    image: nextcloud:stable-fpm-alpine
    container_name: nextcloud
    environment:
      PUID: 1000
      PGID: 1000
      TZ: ${TZ}
      POSTGRES_DB: nextcloud
      POSTGRES_USER: ${PG_USER}
      POSTGRES_PASSWORD: ${PG_PASSWORD}
      POSTGRES_HOST: postgres:5432
      NEXTCLOUD_TRUSTED_DOMAINS: nextcloud.${HOST}
      REDIS_HOST: redis
      REDIS_HOST_PASSWORD: ${REDIS_PASSWORD}
    volumes:
      - nextcloud-config:/config:rw
      - nextcloud-data:/var/data:rw
      - nextcloud-www:/var/www/html:rw
    restart: unless-stopped
    networks:
      - inner
    depends_on:
      postgres:
        condition: service_healthy
      redis:
        condition: service_started

  nextcloud-cron:
    image: nextcloud:stable-fpm-alpine
    restart: always
    container_name: nextcloud-cron
    environment:
      PUID: 1000
      PGID: 1000
      TZ: ${TZ}
      POSTGRES_DB: nextcloud
      POSTGRES_USER: ${PG_USER}
      POSTGRES_PASSWORD: ${PG_PASSWORD}
      POSTGRES_HOST: postgres:5432
      NEXTCLOUD_TRUSTED_DOMAINS: nextcloud.${HOST}
      REDIS_HOST: redis
      REDIS_HOST_PASSWORD: ${REDIS_PASSWORD}
    volumes:
      - nextcloud-config:/config:rw
      - nextcloud-data:/data:rw
      - nextcloud-www:/var/www/html:rw
    entrypoint: /cron.sh
    networks:
      - inner
    depends_on:
      postgres:
        condition: service_healthy
      redis:
        condition: service_started

  vaultwarden:
    image: vaultwarden/server:latest
    container_name: vaultwarden
    restart: always
    environment:
      PUID: 1000
      PGID: 1000
      TZ: ${TZ}
      WEBSOCKET_ENABLED: "true"
      DATABASE_URL: postgresql://${PG_USER}:${PG_PASSWORD}@postgres:5432/vaultwarden
    volumes:
      - vw-data:/data
    networks:
      - inner
    depends_on:
      postgres:
        condition: service_healthy

  gateway:
    image: caddy:2
    container_name: caddy
    restart: always
    ports:
      - 80:80
      - 443:443
    volumes:
      - ./etc/Caddyfile:/etc/caddy/Caddyfile:ro
      - caddy-config:/config:rw
      - caddy-data:/data:rw
      - nextcloud-www:/var/www/nextcloud:rw
    environment:
      PUID: 1000
      PGID: 1000
      TZ: ${TZ}
      HOST: ${HOST}
      EMAIL: ${EMAIL}
      LOG_FILE: "/data/access.log"
    networks:
      - inner
    depends_on:
      - nextcloud
      - vaultwarden
      - transmission

  postgres:
    image: postgres:15.2-alpine3.17
    restart: always
    container_name: postgres
    environment:
      PUID: 1000
      PGID: 1000
      TZ: ${TZ}
      PGUSER: ${PG_USER}
      POSTGRES_USER: ${PG_USER}
      POSTGRES_PASSWORD: ${PG_PASSWORD}
      DB_NAME: nextcloud,vaultwarden
      LANG: ru_RU.utf8
    volumes:
      - "postgres-data:/var/lib/postgresql/data"
      - "./etc/init.sql:/docker-entrypoint-initdb.d/init.sql"
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -d vaultwarden -U docker"]
      interval: 20s
      timeout: 10s
      retries: 10
    networks:
      - inner

  backups:
    image: postgres:15.2-alpine3.17
    container_name: postgres_backup
    # Run nextcloud-restore-application-data.sh to restore application data if needed.
    # Run nextcloud-restore-database.sh to restore database if needed.
    command: sh -c 'sleep 30m
             && while true; do
             PGPASSWORD="$$(echo $$POSTGRES_PASSWORD)"
             pg_dump
             -h postgres
             -p 5432
             -d nextcloud
             -U docker | gzip > /srv/nextcloud-postgres/backups/nextcloud-postgres-backup-$$(date "+%Y-%m-%d_%H-%M").gz
             && tar -zcpf /srv/nextcloud-application-data/backups/nextcloud-application-data-backup-$$(date "+%Y-%m-%d_%H-%M").tar.gz /var/www/html
             && find /srv/nextcloud-postgres/backups -type f -mtime +7 | xargs rm -f
             && find /srv/nextcloud-application-data/backups -type f -mtime +7 | xargs rm -f;
             sleep 24h; done'
    environment:
      PUID: 1000
      PGID: 1000
      TZ: ${TZ}
      PGUSER: ${PG_USER}
      POSTGRES_USER: ${PG_USER}
      POSTGRES_PASSWORD: ${PG_PASSWORD}
      DB_NAME: nextcloud,vaultwarden
      LANG: ru_RU.utf8
    volumes:
      - "postgres-data:/var/lib/postgresql/data"
      # Database backups location
      - "postgres-backups:/srv/nextcloud-postgres/backups"
    restart: unless-stopped
    depends_on:
      postgres: 
        condition: service_healthy

  redis:
    container_name: redis
    image: redis:alpine3.17
    restart: always
    mem_limit: 2048m
    mem_reservation: 512m
    command: redis-server --requirepass $REDIS_PASSWORD
    networks:
      - inner