diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..55af2c41 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,8 @@ +target +node_modules +**/dist +**/*/node_modules +.DS_Store +Dockerfile +*.ddb +*.ddb.wal \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..9017e180 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,29 @@ +FROM node:22 + +RUN apt-get update && apt-get install -y curl + +RUN curl -fsSL https://bun.sh/install | bash + +RUN npm install -g turbo + +ENV PATH="/root/.bun/bin:${PATH}" + +WORKDIR /app + +COPY ./apps ./apps + +COPY ./crates ./crates + +COPY ./package.json ./package.json + +COPY ./bun.lock ./bun.lock + +COPY ./turbo.json ./turbo.json + +RUN bun install + +EXPOSE 8000 + +EXPOSE 3004 + +CMD ["turbo", "db:migrate", "prod:all", "--filter=@rocksky/api"] \ No newline at end of file diff --git a/apps/api/package.json b/apps/api/package.json index 50c08d3c..004fbc46 100644 --- a/apps/api/package.json +++ b/apps/api/package.json @@ -18,7 +18,8 @@ "dev:xrpc": "tsx --watch ./src/server.ts", "prod:xrpc": "tsx ./src/server.ts", "db:migrate": "drizzle-kit migrate", - "db:gen-migration": "drizzle-kit generate" + "db:gen-migration": "drizzle-kit generate", + "prod:all": "concurrently 'tsx ./src/index.ts' 'tsx ./src/server.ts'" }, "dependencies": { "@atproto/api": "^0.13.31", diff --git a/crates/analytics/Dockerfile b/crates/analytics/Dockerfile new file mode 100644 index 00000000..a2b46a15 --- /dev/null +++ b/crates/analytics/Dockerfile @@ -0,0 +1,35 @@ +FROM rust:1.88-bookworm AS builder + +RUN apt-get update && apt-get install -y \ + curl \ + wget \ + unzip \ + libssl-dev \ + pkg-config \ + build-essential \ + cmake + +RUN wget https://github.com/duckdb/duckdb/releases/download/v1.3.2/libduckdb-linux-amd64.zip && \ + unzip libduckdb-linux-amd64.zip && \ + mv libduckdb.so /usr/lib && \ + mv libduckdb_static.a /usr/lib && \ + mv duckdb.h /usr/include && \ + mv duckdb.hpp /usr/include + +WORKDIR /app + +COPY ./crates/analytics ./crates/analytics +COPY Cargo.toml . +COPY Cargo.lock . + +RUN cargo build --release -p analytics + +FROM debian:bookworm-slim + +COPY --from=builder /app/target/release/analytics /usr/local/bin/analytics + +COPY --from=builder /usr/lib/libduckdb.so /usr/lib/libduckdb.so + +EXPOSE 7879 + +CMD ["analytics"] diff --git a/crates/dropbox/Dockerfile b/crates/dropbox/Dockerfile new file mode 100644 index 00000000..2c60ea82 --- /dev/null +++ b/crates/dropbox/Dockerfile @@ -0,0 +1,23 @@ +FROM rust:1.88-bookworm AS builder + +RUN apt-get update && apt-get install -y \ + libssl-dev \ + pkg-config \ + build-essential + + +WORKDIR /app + +COPY ./crates/dropbox ./crates/dropbox +COPY Cargo.toml . +COPY Cargo.lock . + +RUN cargo build --release -p dropbox + +FROM debian:bookworm-slim + +COPY --from=builder /app/target/release/dropbox /usr/local/bin/dropbox + +EXPOSE 7881 + +CMD ["dropbox"] diff --git a/crates/googledrive/Dockerfile b/crates/googledrive/Dockerfile new file mode 100644 index 00000000..2df0ff25 --- /dev/null +++ b/crates/googledrive/Dockerfile @@ -0,0 +1,23 @@ +FROM rust:1.88-bookworm AS builder + +RUN apt-get update && apt-get install -y \ + libssl-dev \ + pkg-config \ + build-essential + + +WORKDIR /app + +COPY ./crates/googledrive ./crates/googledrive +COPY Cargo.toml . +COPY Cargo.lock . + +RUN cargo build --release -p googledrive + +FROM debian:bookworm-slim + +COPY --from=builder /app/target/release/googledrive /usr/local/bin/googledrive + +EXPOSE 7880 + +CMD ["googledrive"] diff --git a/crates/jetstream/Dockerfile b/crates/jetstream/Dockerfile new file mode 100644 index 00000000..958fc821 --- /dev/null +++ b/crates/jetstream/Dockerfile @@ -0,0 +1,23 @@ +FROM rust:1.88-bookworm AS builder + +RUN apt-get update && apt-get install -y \ + libssl-dev \ + pkg-config \ + build-essential + + +WORKDIR /app + +COPY ./crates/jetstream ./crates/jetstream +COPY Cargo.toml . +COPY Cargo.lock . + +RUN cargo build --release -p jetstream + +FROM debian:bookworm-slim + +COPY --from=builder /app/target/release/jetstream /usr/local/bin/jetstream + +EXPOSE 7880 + +CMD ["jetstream"] diff --git a/crates/scrobbler/Dockerfile b/crates/scrobbler/Dockerfile new file mode 100644 index 00000000..9578538d --- /dev/null +++ b/crates/scrobbler/Dockerfile @@ -0,0 +1,23 @@ +FROM rust:1.88-bookworm AS builder + +RUN apt-get update && apt-get install -y \ + libssl-dev \ + pkg-config \ + build-essential + + +WORKDIR /app + +COPY ./crates/scrobbler ./crates/scrobbler +COPY Cargo.toml . +COPY Cargo.lock . + +RUN cargo build --release -p scrobbler + +FROM debian:bookworm-slim + +COPY --from=builder /app/target/release/scrobbler /usr/local/bin/scrobbler + +EXPOSE 7882 + +CMD ["scrobbler"] diff --git a/crates/spotify/Dockerfile b/crates/spotify/Dockerfile new file mode 100644 index 00000000..040874bf --- /dev/null +++ b/crates/spotify/Dockerfile @@ -0,0 +1,21 @@ +FROM rust:1.88-bookworm AS builder + +RUN apt-get update && apt-get install -y \ + libssl-dev \ + pkg-config \ + build-essential + + +WORKDIR /app + +COPY ./crates/spotify ./crates/spotify +COPY Cargo.toml . +COPY Cargo.lock . + +RUN cargo build --release -p spotify + +FROM debian:bookworm-slim + +COPY --from=builder /app/target/release/spotify /usr/local/bin/spotify + +CMD ["spotify"] diff --git a/crates/storage/Dockerfile b/crates/storage/Dockerfile new file mode 100644 index 00000000..fdf10ac2 --- /dev/null +++ b/crates/storage/Dockerfile @@ -0,0 +1 @@ +FROM rust:1.88-bookworm AS builder \ No newline at end of file diff --git a/crates/webscrobbler/Dockerfile b/crates/webscrobbler/Dockerfile new file mode 100644 index 00000000..67884568 --- /dev/null +++ b/crates/webscrobbler/Dockerfile @@ -0,0 +1,23 @@ +FROM rust:1.88-bookworm AS builder + +RUN apt-get update && apt-get install -y \ + libssl-dev \ + pkg-config \ + build-essential + + +WORKDIR /app + +COPY ./crates/webscrobbler ./crates/webscrobbler +COPY Cargo.toml . +COPY Cargo.lock . + +RUN cargo build --release -p webscrobbler + +FROM debian:bookworm-slim + +COPY --from=builder /app/target/release/webscrobbler /usr/local/bin/webscrobbler + +EXPOSE 7883 + +CMD ["webscrobbler"] diff --git a/turbo.json b/turbo.json index 33307573..4ad99a1f 100644 --- a/turbo.json +++ b/turbo.json @@ -43,6 +43,9 @@ "pkl:gen": { "cache": false }, + "prod:all": { + "cache": false + }, "start": { "persistent": true, "cache": false