-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathDockerfile
More file actions
55 lines (41 loc) · 1.54 KB
/
Dockerfile
File metadata and controls
55 lines (41 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# Stage 1: Builder
FROM node:20-bullseye-slim AS builder
# Install prerequisites
RUN apt-get update && apt-get install -y curl unzip build-essential pkg-config libssl-dev
# Install Rust for FFI build
RUN curl https://sh.rustup.rs -sSf | sh -s -- -y
ENV PATH="/root/.cargo/bin:${PATH}"
# Install Bun
RUN curl -fsSL https://bun.sh/install | bash \
&& ln -s $HOME/.bun/bin/bun /usr/local/bin/bun
# Install all base packages
WORKDIR /usr/src/Yuuko
COPY package.json bun.lock ./
RUN bun install --frozen-lockfile
COPY . .
# Build the Rust FFI module
RUN bun run module:build
# Run DB migrations if SQLite database doesn't exist
RUN mkdir -p ./src/database/sqlite
RUN if [ ! -f ./src/database/sqlite/*.sqlite ]; then bun db:push; fi
# Stage 2: Release
FROM node:20-bullseye-slim AS release
WORKDIR /usr/src/Yuuko
# Install production dependencies and CA certificates
RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates \
&& update-ca-certificates \
&& rm -rf /var/lib/apt/lists/*
COPY --from=builder /root/.bun /root/.bun
ENV PATH="/root/.bun/bin:${PATH}"
# Install production-only dependencies
COPY package.json bun.lock ./
RUN bun install --frozen-lockfile --production
# Copy source and compiled FFI
COPY --from=builder /usr/src/Yuuko/src ./src
COPY --from=builder /usr/src/Yuuko/package.json \
/usr/src/Yuuko/tsconfig.json \
/usr/src/Yuuko/drizzle.config.ts \
/usr/src/Yuuko/entrypoint.sh ./
EXPOSE 3030/tcp
VOLUME "/usr/src/Yuuko/src/database/sqlite"
CMD bun start