diff --git a/.gitignore b/.gitignore index da1a81b..d5621cf 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,3 @@ **/node_modules node_modules .env -.sqlx \ No newline at end of file diff --git a/.preludeignore b/.preludeignore new file mode 100644 index 0000000..08db334 --- /dev/null +++ b/.preludeignore @@ -0,0 +1,2 @@ +.sqlx +.env \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index 05f8463..eb85298 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,31 +2,6 @@ # It is not intended for manual editing. version = 4 -[[package]] -name = "SimpleLink" -version = "0.1.0" -dependencies = [ - "actix-cors", - "actix-web", - "anyhow", - "argon2", - "base62", - "chrono", - "clap", - "dotenv", - "jsonwebtoken", - "lazy_static", - "regex", - "serde", - "serde_json", - "sqlx", - "thiserror 1.0.69", - "tokio", - "tracing", - "tracing-subscriber", - "uuid", -] - [[package]] name = "actix-codec" version = "0.5.2" @@ -2039,6 +2014,31 @@ dependencies = [ "time", ] +[[package]] +name = "simplelink" +version = "0.1.0" +dependencies = [ + "actix-cors", + "actix-web", + "anyhow", + "argon2", + "base62", + "chrono", + "clap", + "dotenv", + "jsonwebtoken", + "lazy_static", + "regex", + "serde", + "serde_json", + "sqlx", + "thiserror 1.0.69", + "tokio", + "tracing", + "tracing-subscriber", + "uuid", +] + [[package]] name = "slab" version = "0.4.9" diff --git a/Cargo.toml b/Cargo.toml index f4fc4e9..a8c9acc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,10 +1,10 @@ [package] -name = "SimpleLink" +name = "simplelink" version = "0.1.0" edition = "2021" [lib] -name = "simple_link" +name = "simplelink" path = "src/lib.rs" [dependencies] diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..75f422a --- /dev/null +++ b/Dockerfile @@ -0,0 +1,45 @@ +# Build stage +FROM rust:latest as builder + +# Install PostgreSQL client libraries and SSL dependencies +RUN apt-get update && \ + apt-get install -y pkg-config libssl-dev libpq-dev && \ + rm -rf /var/lib/apt/lists/* + +WORKDIR /usr/src/app + +# Copy manifests first (better layer caching) +COPY Cargo.toml Cargo.lock ./ + +# Copy source code and SQLx prepared queries +COPY src/ src/ +COPY migrations/ migrations/ +COPY .sqlx/ .sqlx/ + +# Build your application +RUN cargo build --release + +# Runtime stage +FROM debian:bookworm-slim + +# Install runtime dependencies +RUN apt-get update && \ + apt-get install -y libpq5 ca-certificates openssl libssl3 && \ + rm -rf /var/lib/apt/lists/* + +WORKDIR /app + +# Copy the binary from builder +COPY --from=builder /usr/src/app/target/release/simplelink /app/simplelink +# Copy migrations folder for SQLx +COPY --from=builder /usr/src/app/migrations /app/migrations + +# Expose the port (this is just documentation) +EXPOSE 8080 + +# Set default network configuration +ENV SERVER_HOST=0.0.0.0 +ENV SERVER_PORT=8080 + +# Run the binary +CMD ["./simplelink"] \ No newline at end of file diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index b212377..2de0985 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -1,51 +1,56 @@ import { ThemeProvider } from "@/components/theme-provider" -import { Button } from './components/ui/button' import { LinkForm } from './components/LinkForm' import { LinkList } from './components/LinkList' import { AuthForms } from './components/AuthForms' import { AuthProvider, useAuth } from './context/AuthContext' -import { useState } from 'react' +import { Button } from "@/components/ui/button" import { Toaster } from './components/ui/toaster' +import { ModeToggle } from './components/mode-toggle' +import { useState } from 'react' function AppContent() { const { user, logout } = useAuth() const [refreshCounter, setRefreshCounter] = useState(0) const handleLinkCreated = () => { - // Increment refresh counter to trigger list refresh setRefreshCounter(prev => prev + 1) } return ( -
Welcome, {user.email}
-A link shortening and tracking service
-