Docker compose setup

This commit is contained in:
Book-reader 2025-09-04 15:53:53 +12:00
parent 24067eca99
commit 1370bc8a43
11 changed files with 240 additions and 5 deletions

4
.gitignore vendored
View file

@ -1,2 +1,6 @@
.idea
/target
# /nginx
database
database.bak
.env

16
Dockerfile.auth-frontend Normal file
View file

@ -0,0 +1,16 @@
FROM rust:1.89.0 AS builder
WORKDIR /usr/src/asklyphe/
COPY asklyphe-auth-frontend asklyphe-auth-frontend
COPY asklyphe-common asklyphe-common
COPY lyphedb lyphedb
RUN cargo install --debug --path asklyphe-auth-frontend/
FROM debian:trixie-slim
RUN apt-get update && apt-get upgrade -y && apt-get install -y libssl3 && rm -rf /var/lib/apt-get/lists/*
COPY --from=builder /usr/local/cargo/bin/asklyphe-auth-frontend /usr/local/bin/
COPY --from=builder /usr/src/asklyphe/asklyphe-auth-frontend/static /data/static
VOLUME /data
CMD ["asklyphe-auth-frontend"]

16
Dockerfile.authservice Normal file
View file

@ -0,0 +1,16 @@
FROM rust:1.89.0 AS builder
WORKDIR /usr/src/asklyphe/
COPY authservice authservice
COPY asklyphe-common asklyphe-common
COPY lyphedb lyphedb
RUN cargo install --debug --path authservice/
RUN cargo install --debug --path authservice/migration/
FROM debian:trixie-slim
RUN apt-get update && apt-get upgrade -y && apt-get install -y libssl3 && rm -rf /var/lib/apt-get/lists/*
COPY --from=builder /usr/local/cargo/bin/authservice /usr/local/bin/
COPY --from=builder /usr/local/cargo/bin/migration /usr/local/bin/
CMD ["authservice"]

14
Dockerfile.bingservice Normal file
View file

@ -0,0 +1,14 @@
FROM rust:1.89.0 AS builder
WORKDIR /usr/src/asklyphe/
COPY bingservice bingservice
COPY asklyphe-common asklyphe-common
COPY lyphedb lyphedb
RUN cargo install --debug --path bingservice/
FROM debian:trixie-slim
RUN apt-get update && apt-get upgrade -y && apt-get install -y libssl3 && rm -rf /var/lib/apt-get/lists/*
COPY --from=builder /usr/local/cargo/bin/bingservice /usr/local/bin/
CMD ["bingservice"]

17
Dockerfile.frontend Normal file
View file

@ -0,0 +1,17 @@
FROM rust:1.89.0 AS builder
WORKDIR /usr/src/asklyphe/
COPY asklyphe-frontend asklyphe-frontend
COPY asklyphe-common asklyphe-common
COPY lyphedb lyphedb
COPY unit_converter unit_converter
RUN cargo install --debug --path asklyphe-frontend/
FROM debian:trixie-slim
RUN apt-get update && apt-get upgrade -y && apt-get install -y libssl3 && rm -rf /var/lib/apt-get/lists/*
COPY --from=builder /usr/local/cargo/bin/asklyphe-frontend /usr/local/bin/
COPY --from=builder /usr/src/asklyphe/asklyphe-frontend/static /data/static
VOLUME /data
CMD ["asklyphe-frontend"]

14
Dockerfile.googleservice Normal file
View file

@ -0,0 +1,14 @@
FROM rust:1.89.0 AS builder
WORKDIR /usr/src/asklyphe/
COPY googleservice googleservice
COPY asklyphe-common asklyphe-common
COPY lyphedb lyphedb
RUN cargo install --debug --path googleservice/
FROM debian:trixie-slim
RUN apt-get update && apt-get upgrade -y && apt-get install -y libssl3 && rm -rf /var/lib/apt-get/lists/*
COPY --from=builder /usr/local/cargo/bin/googleservice /usr/local/bin/
CMD ["googleservice"]

14
Dockerfile.vorebot Normal file
View file

@ -0,0 +1,14 @@
FROM rust:1.89.0 AS builder
WORKDIR /usr/src/asklyphe/
COPY vorebot vorebot
COPY asklyphe-common asklyphe-common
COPY lyphedb lyphedb
RUN cargo install --debug --path vorebot/
FROM debian:trixie-slim
RUN apt-get update && apt-get upgrade -y && apt-get install -y libssl3 && rm -rf /var/lib/apt-get/lists/*
COPY --from=builder /usr/local/cargo/bin/vorebot /usr/local/bin/
CMD ["vorebot"]

View file

@ -17,7 +17,7 @@ mod login;
use std::{env, process};
use std::collections::HashMap;
use std::net::SocketAddr;
use std::net::{SocketAddr, ToSocketAddrs};
use std::ops::Deref;
use std::sync::Arc;
use std::sync::atomic::{AtomicU64, Ordering};
@ -66,7 +66,7 @@ async fn main() {
env_logger::init();
let opts = Opts {
bind_addr: env::var("BIND_ADDR").unwrap_or("0.0.0.0:5843".to_string()).parse().expect("Badly formed BIND_ADDR (Needs to be SocketAddr)"),
nats_addr: env::var("NATS_ADDR").unwrap_or("127.0.0.1:4222".to_string()).parse().expect("Badly formed NATS_ADDR (Needs to be SocketAddr)"),
nats_addr: env::var("NATS_ADDR").unwrap_or("127.0.0.1:4222".to_string()).to_socket_addrs().expect("Badly formed NATS_ADDR (Needs to be SocketAddr)").nth(0).unwrap(),
nats_cert: env::var("NATS_CERT").expect("NATS_CERT needs to be set"),
nats_key: env::var("NATS_KEY").expect("NATS_KEY needs to be set"),
asklyphe_url: env::var("ASKLYPHE_URL").unwrap_or("https://asklyphe.com".to_string()),

View file

@ -19,7 +19,7 @@ pub mod routes;
use std::{env, process};
use std::collections::HashMap;
use std::net::SocketAddr;
use std::net::{SocketAddr, ToSocketAddrs};
use std::ops::Deref;
use std::sync::Arc;
use std::sync::atomic::{AtomicU64, Ordering};
@ -85,7 +85,7 @@ async fn main() {
env_logger::init();
let opts = Opts {
bind_addr: env::var("BIND_ADDR").unwrap_or("0.0.0.0:5842".to_string()).parse().expect("Badly formed BIND_ADDR (Needs to be SocketAddr)"),
nats_addr: env::var("NATS_ADDR").unwrap_or("127.0.0.1:4222".to_string()).parse().expect("Badly formed NATS_ADDR (Needs to be SocketAddr)"),
nats_addr: env::var("NATS_ADDR").unwrap_or("127.0.0.1:4222".to_string()).to_socket_addrs().expect("Badly formed NATS_ADDR (Needs to be SocketAddr)").nth(0).unwrap(),
nats_cert: env::var("NATS_CERT").expect("NATS_CERT needs to be set"),
nats_key: env::var("NATS_KEY").expect("NATS_KEY needs to be set"),
auth_url: env::var("AUTH_URL").unwrap_or("https://auth.asklyphe.com".to_string()),

113
docker-compose.yml Normal file
View file

@ -0,0 +1,113 @@
services:
auth-frontend:
restart: unless-stopped
networks:
- lyphenet
env_file: ".env"
depends_on:
- nats
- authservice
build:
dockerfile: Dockerfile.auth-frontend
volumes:
- auth_frontend_data:/data
image: asklyphe/auth-frontend
authservice:
restart: unless-stopped
networks:
- lyphenet
env_file: ".env"
depends_on:
- nats
build:
dockerfile: Dockerfile.authservice
image: asklyphe/authservice
frontend:
restart: unless-stopped
networks:
- lyphenet
env_file: ".env"
depends_on:
- nats
build:
dockerfile: Dockerfile.frontend
volumes:
- frontend_data:/data
image: asklyphe/frontend
# vorebot:
# restart: unless-stopped
# networks:
# - lyphenet
# - outer
# env_file: ".env"
# depends_on:
# - nats
# build:
# dockerfile: Dockerfile.vorebot
# image: asklyphe/vorebot
# bingservice:
# restart: unless-stopped
# networks:
# - lyphenet
# - outer
# env_file: ".env"
# depends_on:
# - nats
# build:
# dockerfile: Dockerfile.bingservice
# image: asklyphe/bingservice
# googleservice:
# restart: unless-stopped
# networks:
# - lyphenet
# env_file: ".env"
# depends_on:
# - nats
# - bingservice
# build:
# dockerfile: Dockerfile.googleservice
# image: asklyphe/googleservice
nats:
restart: unless-stopped
networks:
- lyphenet
depends_on:
- db
env_file: ".env"
image: nats:2.11.8
cmd: "nats-server -js"
db:
image: postgres:17
networks:
- lyphenet
env_file: ".env"
healthcheck:
test: ['CMD', 'pg_isready', '-U', 'postgres']
volumes:
- ./database:/var/lib/postgresql/data
proxy:
image: nginx:latest
networks:
- lyphenet
- outer
depends_on:
- frontend
- auth-frontend
volumes:
- ./nginx:/etc/nginx/conf.d
- frontend_data:/data/frontend
- auth_frontend_data:/data/auth-frontend
ports:
- "1234:80"
- "1235:81"
networks:
lyphenet:
internal: true
outer:
volumes:
frontend_data:
auth_frontend_data:

27
nginx/default.conf Normal file
View file

@ -0,0 +1,27 @@
server {
listen 81;
server_name 0.0.0.0;
access_log off;
location /static/ {
root /data/auth-frontend;
}
location / {
proxy_pass http://auth-frontend:5843;
}
}
server {
listen 80;
server_name 0.0.0.0;
access_log off;
location /static/ {
root /data/frontend;
}
location / {
proxy_pass http://frontend:5842;
}
}