Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move docker to rust #70

Merged
merged 4 commits into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 10 additions & 20 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,27 +1,19 @@
# Build backend
FROM golang:1.22.1-alpine3.19 as build_backend
FROM rust:1.81-alpine3.20 as build_backend

RUN apk add upx alpine-sdk
RUN apk add upx musl-dev

WORKDIR /

COPY vingo/go.sum go.sum
COPY vingo/Cargo.* .

COPY vingo/go.mod go.mod
COPY vingo/migration migration

RUN go mod download

COPY vingo/main.go .

COPY vingo/database database

COPY vingo/handlers handlers

RUN CGO_ENABLED=1 go build -ldflags "-s -w" -v -tags musl vingo/.

RUN upx --best --lzma vingo
COPY vingo/src src

RUN cargo build --release

RUN upx --best --lzma target/release/vingo

# Build frontend
FROM node:20.15.1-alpine3.20 as build_frontend
Expand All @@ -40,17 +32,15 @@ COPY vinvoor/production.env .env

RUN yarn run build



# End container
FROM alpine:3.19
FROM alpine:3.20

WORKDIR /

COPY --from=build_backend vingo .
COPY --from=build_backend target/release/vingo .
COPY --from=build_frontend /dist public

ENV DEVELOPMENT=false
ENV DEVELOPMENT=FALSE

EXPOSE 4000

Expand Down
46 changes: 46 additions & 0 deletions vingo/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions vingo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ tokio = { version = "1.39.3", default-features = false, features = [
tower-http = { version = "0.5.2", default-features = false, features = [
"trace",
"cors",
"fs",
] }
tower-sessions = { version = "0.12.3", default-features = false, features = [
"memory-store",
Expand Down
15 changes: 12 additions & 3 deletions vingo/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ mod entities;
mod middleware;
mod routes;

use std::sync::Arc;
use std::{env, sync::Arc};

use chrono::Local;
use routes::{auth, cards, days, leaderboard, scans, seasons, settings};
Expand All @@ -15,7 +15,10 @@ use axum::{
use sea_orm::{prelude::DateTimeWithTimeZone, Database, DatabaseConnection};
use tokio::sync::Mutex;
use tower_http::cors::CorsLayer;
use tower_http::trace::TraceLayer;
use tower_http::{
services::{ServeDir, ServeFile},
trace::TraceLayer,
};
use tower_sessions::{cookie::SameSite, MemoryStore, SessionManagerLayer};

use migration::{Migrator, MigratorTrait};
Expand Down Expand Up @@ -60,13 +63,19 @@ async fn main() {
};

// build our application with a route
let app = Router::new()
let mut app = Router::new()
.nest("/api", routes())
.layer(sess_mw)
.layer(CorsLayer::very_permissive())
.layer(TraceLayer::new_for_http())
.with_state(state);

if env::var("DEVELOPMENT").unwrap_or("".into()) != "TRUE" {
app = app.fallback_service(
ServeDir::new("public").not_found_service(ServeFile::new("public/index.html")),
);
};

// run it
let listener = tokio::net::TcpListener::bind("0.0.0.0:4000").await.unwrap();

Expand Down
2 changes: 1 addition & 1 deletion vinvoor/src/overview/heatmap/Rect.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { FC } from "react";
import { HeatmapRectStyle } from "../../theme";
import { RECT_RADIUS, RECT_SIZE, RECT_STROKE, SPACE } from "./utils";
import { HeatmapRectStyle } from "../../themes/theme";

interface RectProps {
idx: number;
Expand Down
Loading