4 Commits

Author SHA1 Message Date
5e31f00b77 fixing name
Some checks failed
CI / Check Style (push) Has been cancelled
CI / Run Clippy (push) Has been cancelled
CI / Run Tests (push) Has been cancelled
2026-05-20 12:15:37 +00:00
8f89423994 prod setup
Some checks failed
CI / Check Style (push) Has been cancelled
CI / Run Clippy (push) Has been cancelled
CI / Run Tests (push) Has been cancelled
2026-05-20 11:01:23 +00:00
Priec
f92cb1f134 caddyfile
Some checks failed
CI / Check Style (push) Has been cancelled
CI / Run Clippy (push) Has been cancelled
CI / Run Tests (push) Has been cancelled
2026-05-20 11:24:06 +02:00
Priec
a385b0540d prod setup is now fully ready 2026-05-20 11:14:42 +02:00
17 changed files with 197 additions and 12 deletions

19
.dockerignore Normal file
View File

@@ -0,0 +1,19 @@
target
node_modules
Dockerfile
.dockerignore
docker-compose.prod.yml
Makefile
Caddyfile
.git
.gitignore
.env
.env.*
*.sqlite
*.sqlite-*
uploads
*report.html

26
.env.production.example Normal file
View File

@@ -0,0 +1,26 @@
CONTAINER_NAME=universal-web
REVERSE_PROXY_NETWORK=
UPLOADS_VOLUME_NAME=universal_web_uploads
APP_HOST=https://gitara.farmeris.sk
PORT=5150
SERVER_BINDING=0.0.0.0
DATABASE_URL=
JWT_SECRET=
ADMIN_EMAIL=
ADMIN_PASSWORD=
ADMIN_NAME=Admin
UPLOADS_ROOT=data/uploads
LOG_LEVEL=info
LOG_FORMAT=compact
MAILER_STUB=true
SMTP_ENABLE=false
SMTP_HOST=localhost
SMTP_PORT=1025
SMTP_SECURE=false
SMTP_USER=
SMTP_PASSWORD=

1
.gitignore vendored
View File

@@ -1,6 +1,5 @@
**/config/local.yaml
**/config/*.local.yaml
**/config/production.yaml
# Generated by Cargo
# will have compiled files and executables

12
Caddyfile Normal file
View File

@@ -0,0 +1,12 @@
gitara.farmeris.sk {
encode gzip
@static path /static/*
header @static Cache-Control "public, max-age=2592000"
reverse_proxy gitara-web:5150
}
www.gitara.farmeris.sk {
redir https://gitara.farmeris.sk{uri} permanent
}

2
Cargo.lock generated
View File

@@ -5053,7 +5053,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853"
[[package]]
name = "universal_web"
name = "gitara_web"
version = "0.1.0"
dependencies = [
"async-trait",

View File

@@ -1,11 +1,11 @@
[workspace]
[package]
name = "universal_web"
name = "gitara_web"
version = "0.1.0"
edition = "2021"
publish = false
default-run = "universal_web-cli"
default-run = "gitara_web-cli"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
@@ -45,7 +45,7 @@ axum-extra = { version = "0.10", features = ["form"] }
bytes = { version = "1" }
[[bin]]
name = "universal_web-cli"
name = "gitara_web-cli"
path = "src/bin/main.rs"
required-features = []

25
Dockerfile Normal file
View File

@@ -0,0 +1,25 @@
FROM rust:1-slim-bookworm AS builder
WORKDIR /usr/src
COPY . .
RUN cargo build --release --bin gitara_web-cli
FROM debian:bookworm-slim
RUN apt-get update \
&& apt-get install -y --no-install-recommends ca-certificates curl \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /usr/app
COPY --from=builder /usr/src/assets assets
COPY --from=builder /usr/src/config config
COPY --from=builder /usr/src/target/release/gitara_web-cli gitara_web-cli
ENV LOCO_ENV=production
EXPOSE 5150
ENTRYPOINT ["/usr/app/gitara_web-cli"]
CMD ["start"]

20
Makefile Normal file
View File

@@ -0,0 +1,20 @@
COMPOSE = docker compose -f docker-compose.prod.yml --env-file .env.production
.PHONY: up down restart logs build ps
up:
$(COMPOSE) up -d --build
down:
$(COMPOSE) down
restart: down up
logs:
$(COMPOSE) logs -f --tail=100
build:
$(COMPOSE) build --no-cache
ps:
$(COMPOSE) ps

View File

@@ -71,7 +71,7 @@ mailer:
# Database Configuration
database:
# Database connection URI
uri: {{ get_env(name="DATABASE_URL", default="postgres://uni_loco_web_user:3@localhost:5432/universal_web_development") }}
uri: {{ get_env(name="DATABASE_URL", default="postgres://uni_loco_web_user:3@localhost:5432/gitara_web_development") }}
# When enabled, the sql query will be logged.
enable_logging: false
# Set the timeout duration when acquiring a connection.

57
config/production.yaml Normal file
View File

@@ -0,0 +1,57 @@
logger:
enable: true
pretty_backtrace: false
level: "{{ get_env(name="LOG_LEVEL", default="info") }}"
format: "{{ get_env(name="LOG_FORMAT", default="compact") }}"
server:
port: {{ get_env(name="PORT", default="5150") }}
binding: "{{ get_env(name="SERVER_BINDING", default="0.0.0.0") }}"
host: "{{ get_env(name="APP_HOST") }}"
middlewares:
static:
enable: true
must_exist: true
precompressed: false
folder:
uri: "/static"
path: "assets/static"
fallback: "assets/static/404.html"
workers:
mode: "{{ get_env(name="WORKER_MODE", default="BackgroundAsync") }}"
mailer:
stub: {{ get_env(name="MAILER_STUB", default="true") }}
smtp:
enable: {{ get_env(name="SMTP_ENABLE", default="false") }}
host: "{{ get_env(name="SMTP_HOST", default="localhost") }}"
port: {{ get_env(name="SMTP_PORT", default="1025") }}
secure: {{ get_env(name="SMTP_SECURE", default="false") }}
auth:
user: "{{ get_env(name="SMTP_USER", default="") }}"
password: "{{ get_env(name="SMTP_PASSWORD", default="") }}"
database:
uri: "{{ get_env(name="DATABASE_URL") }}"
enable_logging: {{ get_env(name="DB_ENABLE_LOGGING", default="false") }}
connect_timeout: {{ get_env(name="DB_CONNECT_TIMEOUT", default="500") }}
idle_timeout: {{ get_env(name="DB_IDLE_TIMEOUT", default="500") }}
min_connections: {{ get_env(name="DB_MIN_CONNECTIONS", default="1") }}
max_connections: {{ get_env(name="DB_MAX_CONNECTIONS", default="5") }}
auto_migrate: {{ get_env(name="DB_AUTO_MIGRATE", default="true") }}
dangerously_truncate: false
dangerously_recreate: false
auth:
jwt:
location:
- from: Cookie
name: auth_token
- from: Bearer
secret: "{{ get_env(name="JWT_SECRET") }}"
expiration: {{ get_env(name="JWT_EXPIRATION", default="604800") }}
settings:
admin_email: "{{ get_env(name="ADMIN_EMAIL", default="") }}"
uploads_root: "{{ get_env(name="UPLOADS_ROOT", default="data/uploads") }}"

View File

@@ -68,7 +68,7 @@ mailer:
# Database Configuration
database:
# Database connection URI
uri: {{ get_env(name="DATABASE_URL", default="postgres://uni_loco_web_user:3@localhost:5432/universal_web_test") }}
uri: {{ get_env(name="DATABASE_URL", default="postgres://uni_loco_web_user:3@localhost:5432/gitara_web_test") }}
# When enabled, the sql query will be logged.
enable_logging: false
# Set the timeout duration when acquiring a connection.

27
docker-compose.prod.yml Normal file
View File

@@ -0,0 +1,27 @@
services:
universal-web:
container_name: gitara-web
build:
context: .
dockerfile: Dockerfile
env_file:
- .env.production
volumes:
- gitara_web_data:/usr/app/data
networks:
- gitara-net
restart: unless-stopped
healthcheck:
test: ["CMD-SHELL", "curl -fsS http://localhost:5150/_ping"]
interval: 30s
timeout: 5s
retries: 3
start_period: 20s
networks:
gitara-net:
external: true
volumes:
gitara_web_data:
name: gitara_web_data

View File

@@ -1,6 +1,6 @@
#[allow(unused_imports)]
use loco_rs::{cli::playground, prelude::*};
use universal_web::app::App;
use gitara_web::app::App;
#[tokio::main]
async fn main() -> loco_rs::Result<()> {

View File

@@ -1,6 +1,6 @@
use loco_rs::cli;
use migration::Migrator;
use universal_web::app::App;
use gitara_web::app::App;
#[tokio::main]
async fn main() -> loco_rs::Result<()> {

View File

@@ -3,7 +3,7 @@ use insta::assert_debug_snapshot;
use loco_rs::testing::prelude::*;
use sea_orm::{ActiveModelTrait, ActiveValue, IntoActiveModel};
use serial_test::serial;
use universal_web::{
use gitara_web::{
app::App,
models::users::{self, Model, RegisterParams},
};

View File

@@ -2,7 +2,7 @@ use insta::{assert_debug_snapshot, with_settings};
use loco_rs::testing::prelude::*;
use rstest::rstest;
use serial_test::serial;
use universal_web::{app::App, models::users};
use gitara_web::{app::App, models::users};
use super::prepare_data;

View File

@@ -1,6 +1,6 @@
use axum::http::{HeaderName, HeaderValue};
use loco_rs::{app::AppContext, TestServer};
use universal_web::{models::users, views::auth::LoginResponse};
use gitara_web::{models::users, views::auth::LoginResponse};
const USER_EMAIL: &str = "test@loco.com";
const USER_PASSWORD: &str = "1234";