docker integration

This commit is contained in:
BENEDEK László 2025-06-10 13:17:20 +02:00
parent 462782b14b
commit 6e65e9a912
5 changed files with 91 additions and 8 deletions

14
.env.api Normal file
View File

@ -0,0 +1,14 @@
API_ADDRESS=:5000
API_BASE=api
API_TOKEN_LIFE=600
DB_HOST=database
DB_PORT=5432
DB_USER=admin
DB_PASSWORD=admin
DB_NAME=chat
VALKEY_ADDRESS=keystore:6379
VALKEY_USERNAME=admin
VALKEY_PASSWORD=admin
VALKEY_DB=0

View File

@ -0,0 +1,23 @@
services:
database:
image: postgres:17-alpine
restart: unless-stopped
ports:
- 5432:5432
env_file: .env.postgres
volumes:
- pgdata:/var/lib/postgresql/data
- ./postgres:/docker-entrypoint-initdb.d:ro
keystore:
image: valkey/valkey:8-alpine
restart: unless-stopped
ports:
- 6379:6379
command: valkey-server /usr/local/etc/valkey/valkey.conf
volumes:
- ./valkey/valkey.conf:/usr/local/etc/valkey/valkey.conf:ro
- ./valkey/users.acl:/usr/local/etc/valkey/users.acl:ro
volumes:
pgdata:

View File

@ -2,8 +2,6 @@ services:
database:
image: postgres:17-alpine
restart: unless-stopped
ports:
- 5432:5432
env_file: .env.postgres
volumes:
- pgdata:/var/lib/postgresql/data
@ -12,12 +10,34 @@ services:
keystore:
image: valkey/valkey:8-alpine
restart: unless-stopped
ports:
- 6379:6379
command: valkey-server /usr/local/etc/valkey/valkey.conf
volumes:
- ./valkey/valkey.conf:/usr/local/etc/valkey/valkey.conf:ro
- ./valkey/users.acl:/usr/local/etc/valkey/users.acl:ro
api:
scale: 1
image: registry.tek.govt.hu/chat/api:latest
restart: unless-stopped
env_file: .env.api
depends_on:
- database
- keystore
ui:
scale: 1
image: registry.tek.govt.hu/chat/ui:debug
restart: unless-stopped
depends_on:
- api
proxy:
image: nginx:alpine-slim
restart: unless-stopped
ports:
- 80:80
volumes:
- ./nginx/default.conf:/etc/nginx/conf.d/default.conf:ro
volumes:
pgdata:

26
nginx/default.conf Normal file
View File

@ -0,0 +1,26 @@
server {
listen 80;
# backend api
location /api/ {
proxy_pass http://api:5000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_read_timeout 86400;
}
# frontend & static
location / {
proxy_pass http://ui:80;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}

View File

@ -1,10 +1,10 @@
-- More users
insert into "user" ("username", "password_hash", "status", "picture", "bio")
values
('alice', '$2a$12$FChbwNEIH9imtkTAkNq35eqMb.1C.1BP3bbuFZwOr7rOrs5luwCzq', 'Online', 'https://example.com/alice.jpg', 'Loves coding and coffee.'),
('bob', '$2a$12$FChbwNEIH9imtkTAkNq35eqMb.1C.1BP3bbuFZwOr7rOrs5luwCzq', 'Away', 'https://example.com/bob.jpg', 'Gamer and tech enthusiast.'),
('charlie', '$2a$12$FChbwNEIH9imtkTAkNq35eqMb.1C.1BP3bbuFZwOr7rOrs5luwCzq', 'Busy', 'https://example.com/charlie.jpg', 'Database aficionado.'),
('diana', '$2a$12$FChbwNEIH9imtkTAkNq35eqMb.1C.1BP3bbuFZwOr7rOrs5luwCzq', 'Online', 'https://example.com/diana.jpg', 'Enjoys reading and hiking.');
('alice', '$2a$12$FChbwNEIH9imtkTAkNq35eqMb.1C.1BP3bbuFZwOr7rOrs5luwCzq', 'Online', '', 'Loves coding and coffee.'),
('bob', '$2a$12$FChbwNEIH9imtkTAkNq35eqMb.1C.1BP3bbuFZwOr7rOrs5luwCzq', 'Away', '', 'Gamer and tech enthusiast.'),
('charlie', '$2a$12$FChbwNEIH9imtkTAkNq35eqMb.1C.1BP3bbuFZwOr7rOrs5luwCzq', 'Busy', '', 'Database aficionado.'),
('diana', '$2a$12$FChbwNEIH9imtkTAkNq35eqMb.1C.1BP3bbuFZwOr7rOrs5luwCzq', 'Online', '', 'Enjoys reading and hiking.');
-- More roles
insert into "role" ("name")