Skip to content

Commit 90529c9

Browse files
committed
feat: docker house keeping
* add specific docker network to allow gateway and subnet configuration * add separate location for pgAdmin in dev mode * add docker container names attribute in addition to service name * add websocket config to nginx.conf from nginx.raw * make network-name configurable Signed-off-by: Daniel Einars <[email protected]>
1 parent 44acda1 commit 90529c9

8 files changed

+44
-10
lines changed

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
include librephotos.env
44
DOCKER_TAG ?= ownphotos-backend
5-
REPLACE_NAMES=sed 's/__backend_name__/$(BACKEND_CONT_NAME)/g; s/__frontend_name__/$(FRONTEND_CONT_NAME)/g; s/__proxy_name__/$(PROXY_CONT_NAME)/g; s/__redis_name__/$(REDIS_CONT_NAME)/g; s/__db_name__/$(DB_CONT_NAME)/g; s/__pgadmin_name__/$(PGADMIN_CONT_NAME)/g'
5+
REPLACE_NAMES=sed 's/__backend_name__/$(BACKEND_CONT_NAME)/g; s/__frontend_name__/$(FRONTEND_CONT_NAME)/g; s/__proxy_name__/$(PROXY_CONT_NAME)/g; s/__redis_name__/$(REDIS_CONT_NAME)/g; s/__db_name__/$(DB_CONT_NAME)/g; s/__pgadmin_name__/$(PGADMIN_CONT_NAME)/g; s/__network_name__/$(NETWORK_NAME)/g'
66

77
default: build
88

docker-compose.dev.raw

+6-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ services:
2121
build:
2222
context: ./proxy
2323
dockerfile: Dockerfile
24+
container_name: __proxy_name__
2425
volumes:
2526
- ${myPhotos}:/data
2627
- ${proMedia}:/protected_media
@@ -30,9 +31,11 @@ services:
3031
tty: true
3132
environment:
3233
- DEBUG=1
34+
- WDS_SOCKET_PORT=0 # needed for webpack-dev-server
3335
build:
3436
context: ./frontend
3537
dockerfile: Dockerfile.dev
38+
container_name: __frontend_name__
3639
volumes:
3740
- ${codedir}/librephotos-frontend:/usr/src/app
3841

@@ -46,6 +49,7 @@ services:
4649
dockerfile: Dockerfile
4750
args:
4851
DEBUG: 1
52+
container_name: __backend_name__
4953
volumes:
5054
- ${myPhotos}:/data
5155
- ${proMedia}:/protected_media
@@ -59,11 +63,12 @@ services:
5963

6064
__pgadmin_name__:
6165
image: dpage/pgadmin4
66+
container_name: __pgadmin_name__
6267
environment:
6368
PGADMIN_DEFAULT_EMAIL: ${PGADMIN_DEFAULT_EMAIL:[email protected]}
6469
PGADMIN_DEFAULT_PASSWORD: ${PGADMIN_DEFAULT_PASSWORD:-admin}
6570
volumes:
66-
- $HOME/pgadmin:/root/.pgadmin
71+
- ${pgAdminLocation}/pgadmin:/root/.pgadmin
6772
ports:
6873
- "3001:80"
6974
restart: unless-stopped

docker-compose.dev.yml

+5-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ services:
2121
build:
2222
context: ./proxy
2323
dockerfile: Dockerfile
24+
container_name: proxy
2425
volumes:
2526
- ${myPhotos}:/data
2627
- ${proMedia}:/protected_media
@@ -34,6 +35,7 @@ services:
3435
build:
3536
context: ./frontend
3637
dockerfile: Dockerfile.dev
38+
container_name: frontend
3739
volumes:
3840
- ${codedir}/librephotos-frontend:/usr/src/app
3941

@@ -47,6 +49,7 @@ services:
4749
dockerfile: Dockerfile
4850
args:
4951
DEBUG: 1
52+
container_name: backend
5053
volumes:
5154
- ${myPhotos}:/data
5255
- ${proMedia}:/protected_media
@@ -60,11 +63,12 @@ services:
6063

6164
pgadmin:
6265
image: dpage/pgadmin4
66+
container_name: pgadmin
6367
environment:
6468
PGADMIN_DEFAULT_EMAIL: ${PGADMIN_DEFAULT_EMAIL:[email protected]}
6569
PGADMIN_DEFAULT_PASSWORD: ${PGADMIN_DEFAULT_PASSWORD:-admin}
6670
volumes:
67-
- $HOME/pgadmin:/root/.pgadmin
71+
- ${pgAdminLocation}/pgadmin:/root/.pgadmin
6872
ports:
6973
- "3001:80"
7074
restart: unless-stopped

docker-compose.raw

+5
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ version: "3.8"
1111
services:
1212
__proxy_name__:
1313
image: reallibrephotos/librephotos-proxy:${tag}
14+
container_name: __proxy_name__
1415
restart: unless-stopped
1516
volumes:
1617
- ${myPhotos}:/data
@@ -24,6 +25,7 @@ services:
2425

2526
__db_name__:
2627
image: postgres:13
28+
container_name: __db_name__
2729
restart: unless-stopped
2830
environment:
2931
- POSTGRES_USER=${dbUser}
@@ -35,12 +37,14 @@ services:
3537

3638
__frontend_name__:
3739
image: reallibrephotos/librephotos-frontend:${tag}
40+
container_name: __frontend_name__
3841
restart: unless-stopped
3942
depends_on:
4043
- __backend_name__
4144

4245
__backend_name__:
4346
image: reallibrephotos/librephotos:${tag}
47+
container_name: __backend_name__
4448
restart: unless-stopped
4549
volumes:
4650
- ${myPhotos}:/data
@@ -75,4 +79,5 @@ services:
7579

7680
__redis_name__:
7781
image: redis:6
82+
container_name: __redis_name__
7883
restart: unless-stopped

docker-compose.yml

+6
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@ version: "3.8"
1111
services:
1212
proxy:
1313
image: reallibrephotos/librephotos-proxy:${tag}
14+
container_name: proxy
1415
restart: unless-stopped
1516
volumes:
1617
- ${myPhotos}:/data
1718
- ${proMedia}:/protected_media
19+
- ./proxy/nginx.conf:/etc/nginx/nginx.conf:ro
1820
ports:
1921
- ${httpPort}:80
2022
depends_on:
@@ -23,6 +25,7 @@ services:
2325

2426
db:
2527
image: postgres:13
28+
container_name: db
2629
restart: unless-stopped
2730
environment:
2831
- POSTGRES_USER=${dbUser}
@@ -34,12 +37,14 @@ services:
3437

3538
frontend:
3639
image: reallibrephotos/librephotos-frontend:${tag}
40+
container_name: frontend
3741
restart: unless-stopped
3842
depends_on:
3943
- backend
4044

4145
backend:
4246
image: reallibrephotos/librephotos:${tag}
47+
container_name: backend
4348
restart: unless-stopped
4449
volumes:
4550
- ${myPhotos}:/data
@@ -74,4 +79,5 @@ services:
7479

7580
redis:
7681
image: redis:6
82+
container_name: redis
7783
restart: unless-stopped

librephotos.env

+10-2
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ shhhhKey=D2VymuMn2gAhx4tmAawd
4242

4343
#What port should Libre Photos be accessed at (Default 3000)
4444
httpPort=3000
45-
4645
# ------------------------------------------------------------------------------------------------
4746

4847
# Wow, we are at the optional now. Pretty easy so far. You do not have to change any of the below.
@@ -86,11 +85,20 @@ FRONTEND_CONT_NAME=frontend
8685
PROXY_CONT_NAME=proxy
8786
REDIS_CONT_NAME=redis
8887
PGADMIN_CONT_NAME=pgadmin
88+
NETWORK_NAME=libre-photos-net
8989

9090
# ---------------------------------------------------------------------------------------------
9191

9292
# If you are not a developer ignore the following parameters: you will never need them.
9393

94-
# Where shall we store the backend and frontend code files.
94+
# Where shall we store the backend and frontend code files.
9595
codedir=./librephotos/code
9696

97+
# Location for pgAdmin
98+
pgAdminLocation=./librephotos/pgadmin
99+
100+
# Which subnet should the docker network use
101+
subnet=172.19.0.0/16
102+
103+
# On which Gateway should the proxy container be accessible
104+
gateway=172.19.0.1

proxy/nginx.conf

+4-5
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,11 @@ http {
2828
}
2929
# needed for webpack-dev-server
3030
location /ws {
31-
proxy_pass http://frontend:3000;
32-
proxy_http_version 1.1;
33-
proxy_set_header Upgrade $http_upgrade;
34-
proxy_set_header Connection "upgrade";
31+
proxy_pass http://frontend:3000;
32+
proxy_http_version 1.1;
33+
proxy_set_header Upgrade $http_upgrade;
34+
proxy_set_header Connection "upgrade";
3535
}
36-
3736
# Django media
3837
location /protected_media {
3938
internal;

proxy/nginx.raw

+7
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@ http {
2626
include uwsgi_params;
2727
proxy_pass http://__backend_name__:8001;
2828
}
29+
# needed for webpack-dev-server
30+
location /ws {
31+
proxy_pass http://__frontend_name__:3000;
32+
proxy_http_version 1.1;
33+
proxy_set_header Upgrade $http_upgrade;
34+
proxy_set_header Connection "upgrade";
35+
}
2936
# Django media
3037
location /protected_media {
3138
internal;

0 commit comments

Comments
 (0)