Skip to content

Commit

Permalink
Initial release
Browse files Browse the repository at this point in the history
  • Loading branch information
slyons committed Jan 1, 2024
1 parent 486532d commit f7f1c50
Show file tree
Hide file tree
Showing 20 changed files with 2,180 additions and 941 deletions.
6 changes: 6 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
target

dockerfile
.dockerignore
.git
.gitignore
10 changes: 6 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ edition = "2021"

[dependencies]

loco-rs = { version = "0.1.8" }
loco-rs = { version = "0.1.9"}
migration = { path = "migration" }

serde = { version = "1", features = ["derive"] }
Expand All @@ -34,10 +34,12 @@ uuid = { version = "1.6.0", features = ["v4"] }
tracing-subscriber = { version = "0.3.17", features = ["env-filter", "json"] }
interface = { version = "0.1.0", path = "interface" }
rand = "0.8.5"
fraction = "0.14.0"
#fraction = "0.14.0"
axum-macros = "0.4.0"
fuzzy_fraction = "0.1.2"
#fuzzy_fraction = "0.1.2"
numfmt = "1.1.1"
rust_decimal = "1.33.1"
rust_decimal_macros = "1.33.1"

[[bin]]
name = "liftcalc-cli"
Expand All @@ -47,7 +49,7 @@ required-features = []
[dev-dependencies]
serial_test = "2.0.0"
rstest = "0.18.2"
loco-rs = { version = "0.1.8", features = ["testing"] }
loco-rs = { version = "0.1.9", features = ["testing", "cli"] }
insta = { version = "1.34.0", features = ["redactions", "yaml", "filters"] }


Expand Down
7 changes: 7 additions & 0 deletions config/development.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ server:
# the limit size. can be b,kb,kib,mb,mib,gb,gib
body_limit: 5mb
# Generating a unique request ID and enhancing logging with additional information such as the start and completion of request processing, latency, status code, and other request details.
static:
enable: true
must_exist: true
folder:
uri: "/"
path: "frontend/dist"
fallback: "frontend/dist/index.html"
logger:
# Enable/Disable the middleware.
enable: true
Expand Down
69 changes: 69 additions & 0 deletions config/production.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
logger:
enable: true
pretty_backtrace: {{ get_env(name="PRETTY_BACKTRACE", default="false") }}
level: {{ get_env(name="LOG_LEVEL", default="info") }}
format: {{ get_env(name="LOG_FORMAT", default="compact") }}

server:
port: 3000
host: 0.0.0.0
middlewares:
limit_payload:
enable: true
body_limit: 5mb
static:
enable: true
must_exist: true
folder:
uri: "/"
path: "frontend/dist"
fallback: "frontend/dist/index.html"
logger:
enable: true
catch_panic:
enable: true
timeout_request:
enable: true
timeout: 5000
cors:
enable: true

workers:
mode: BackgroundQueue

mailer:
# SMTP mailer configuration.
smtp:
# Enable/Disable smtp mailer.
enable: false
# SMTP server host. e.x localhost, smtp.gmail.com
host: {{ get_env(name="MAILER_HOST", default="localhost") }}
# SMTP server port
port: 1025
# Use secure connection (SSL/TLS).
secure: false

database:
uri: {{ get_env(name="DATABASE_URL") }}
enable_logging: {{ get_env(name="DB_LOGGING", default="false") }}
connect_timeout: 500
idle_timeout: 500
min_connections: 1
max_connections: 1
auto_migrate: true
dangerously_truncate: false
dangerously_recreate: false

redis:
# Redis connection URI
uri: {{ get_env(name="REDIS_URL", default="redis://127.0.0.1") }}
# Dangerously flush all data in Redis on startup. dangerous operation, make sure that you using this flag only on dev environments or test mode
dangerously_flush: false

auth:
# JWT authentication
jwt:
# Secret key for token generation and verification
secret: {{ get_env(name="JWT_SECRET") }}
# Token expiration time in seconds
expiration: 604800 # 7 days
20 changes: 20 additions & 0 deletions dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM rust:1.74-slim as builder

WORKDIR /usr/src/

COPY . .

RUN cargo build --release

FROM debian:bookworm-slim

WORKDIR /usr/app

COPY --from=builder /usr/src/frontend/dist /usr/app/frontend/dist
COPY --from=builder /usr/src/frontend/dist/index.html /usr/app/frontend/dist/index.html
COPY --from=builder /usr/src/config /usr/app/config
COPY --from=builder /usr/src/target/release/liftcalc-cli /usr/app/liftcalc-cli

ENTRYPOINT ["/usr/app/liftcalc-cli"]

CMD ["start", "-e", "production"]
35 changes: 35 additions & 0 deletions fly.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# fly.toml app configuration file generated for liftcalc-cool-bush-2100 on 2023-12-30T19:14:08-08:00
#
# See https://fly.io/docs/reference/configuration/ for information about how to use this file.
#

app = "liftcalc"
primary_region = "sea"

[build]

[http_service]
internal_port = 3000
force_https = true
auto_stop_machines = true
auto_start_machines = true
min_machines_running = 0
processes = ["app"]

[checks]
[checks.name_of_your_http_check]
grace_period = "30s"
interval = "15s"
method = "get"
path = "/api/_health"
port = 5500
timeout = "10s"
type = "http"

[env]
RAILS_ENV="production"

[[vm]]
cpu_kind = "shared"
cpus = 1
memory_mb = 1024
3 changes: 2 additions & 1 deletion frontend/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,6 @@ anyhow = "1.0.76"
serde = { version = "1.0.193", features = ["derive"] }
gloo-storage = "0.3.0"
eyre = "0.6.11"
thaw = { version = "0.1.5", features = ["leptos_meta"] }
#thaw = { version = "0.1.5", features = ["leptos_meta"] }
leptos_animated_for = "0.1.0"

Loading

0 comments on commit f7f1c50

Please sign in to comment.