@@ -8,9 +8,7 @@ RUN apt-get update && apt-get install -y \
88 curl \
99 build-essential \
1010 protobuf-compiler \
11- sqlite3 \
1211 unzip \
13- libsqlite3-dev \
1412 g++ \
1513 cmake \
1614 zlib1g-dev \
@@ -24,61 +22,76 @@ ENV RUSTC_WRAPPER=sccache
2422
2523# Create a new empty shell project with only Cargo files
2624WORKDIR /usr/src/nebulous
27- # Copy Cargo.toml first and handle missing Cargo.lock
28- COPY Cargo.toml ./
29- # Create empty Cargo.lock if it doesn't exist
30- RUN touch Cargo.lock
3125
32- # Pre-build dependencies to leverage Docker layer caching
33- RUN cargo build --release || true
26+ COPY Cargo.toml Cargo.lock* ./
3427
35- # Now copy actual source code
28+ # Create a dummy main.rs to build dependencies
29+ RUN mkdir src && \
30+ echo "fn main() {}" > src/main.rs && \
31+ echo "pub fn lib() {}" > src/lib.rs
32+
33+ RUN cargo build --release
34+
35+ # Remove the dummy files and copy actual source code
36+ RUN rm -rf src
3637COPY . .
3738
38- # Build with release profile
39+ # Build with release profile (this will reuse the cached dependencies)
3940RUN cargo build --release
4041
41- # Runtime stage
42- FROM debian:bullseye-slim
42+ # Tools stage - install runtime tools
43+ FROM debian:bullseye-slim AS tools
4344
44- # Install runtime dependencies
45+ # Install runtime dependencies and tools in a single layer
4546RUN apt-get update && apt-get install -y \
4647 ca-certificates \
47- sqlite3 \
48- libsqlite3-0 \
4948 curl \
5049 unzip \
5150 openssh-client \
51+ gnupg \
5252 && rm -rf /var/lib/apt/lists/*
5353
54- # Copy the binary from builder - fix the binary name
55- COPY --from=builder /usr/src/nebulous/target/release/nebulous /usr/local/bin/nebulous
54+ # Install rclone, AWS CLI, and Tailscale in parallel
55+ RUN curl -fsSL https://rclone.org/install.sh | bash && \
56+ curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" && \
57+ unzip awscliv2.zip && \
58+ ./aws/install && \
59+ rm -rf awscliv2.zip aws && \
60+ curl -fsSL https://pkgs.tailscale.com/stable/debian/bullseye.noarmor.gpg | tee /usr/share/keyrings/tailscale-archive-keyring.gpg >/dev/null && \
61+ curl -fsSL https://pkgs.tailscale.com/stable/debian/bullseye.tailscale-keyring.list | tee /etc/apt/sources.list.d/tailscale.list && \
62+ apt-get update && apt-get install -y tailscale && \
63+ rm -rf /var/lib/apt/lists/*
5664
57- # Create a symlink for the 'nebu' command to point to 'nebulous'
58- RUN ln -s /usr/local/bin/nebulous /usr/local/bin/nebu
65+ # Runtime stage
66+ FROM debian:bullseye-slim
5967
60- # Install rclone
61- RUN curl https://rclone.org/install.sh | bash
68+ # Copy tools from tools stage
69+ COPY --from=tools /usr/bin/rclone /usr/bin/rclone
70+ COPY --from=tools /usr/local/bin/aws /usr/local/bin/aws
6271
63- # Install AWS CLI
64- RUN curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" && \
65- unzip awscliv2.zip && \
66- ./aws/install && \
67- rm -rf awscliv2.zip aws
72+ # Install runtime dependencies including Tailscale
73+ RUN apt-get update && apt-get install -y \
74+ ca-certificates \
75+ openssh-client \
76+ curl \
77+ gnupg \
78+ && curl -fsSL https://pkgs.tailscale.com/stable/debian/bullseye.noarmor.gpg | tee /usr/share/keyrings/tailscale-archive-keyring.gpg >/dev/null \
79+ && curl -fsSL https://pkgs.tailscale.com/stable/debian/bullseye.tailscale-keyring.list | tee /etc/apt/sources.list.d/tailscale.list \
80+ && apt-get update && apt-get install -y tailscale \
81+ && rm -rf /var/lib/apt/lists/*
82+
83+ # Copy the binary from builder
84+ COPY --from=builder /usr/src/nebulous/target/release/nebulous /usr/local/bin/nebulous
6885
69- # Install Tailscale
70- # RUN curl -fsSL https://tailscale.com/install.sh | sh
71- RUN curl -fsSL https://pkgs.tailscale.com/stable/debian/bullseye.noarmor.gpg | tee /usr/share/keyrings/tailscale-archive-keyring.gpg >/dev/null
72- RUN curl -fsSL https://pkgs.tailscale.com/stable/debian/bullseye.tailscale-keyring.list | tee /etc/apt/sources.list.d/tailscale.list
73- RUN apt-get update && apt-get install -y tailscale
86+ # Create a symlink for the 'nebu' command to point to 'nebulous'
87+ RUN ln -s /usr/local/bin/nebulous /usr/local/bin/nebu
7488
7589# Create directory for SQLite database
7690RUN mkdir -p /data
7791WORKDIR /data
7892
7993# Set environment variables
8094ENV RUST_LOG=info
81- ENV DATABASE_URL=sqlite:/data/nebulous.db
8295
8396# Expose the default port
8497EXPOSE 3000
0 commit comments