@@ -3,29 +3,43 @@ FROM rust:alpine AS builder
33# Install build dependencies
44RUN apk update && apk upgrade && \
55 apk add --no-cache musl-dev libffi-dev zlib-dev jpeg-dev
6- # Install wasm target and build tools
7- RUN rustup target add wasm32-unknown-unknown && \
8- cargo install wasm-bindgen-cli
96RUN apk update && apk upgrade
107# Add the Edge Community repository
118RUN echo "@edge http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories
129# Update the package index
1310RUN apk update
1411# Install the desired package from the edge community repository
1512RUN apk add trunk@edge
13+ # Install wasm target and build tools
14+ RUN rustup target add wasm32-unknown-unknown && \
15+ cargo install wasm-bindgen-cli
1616# Add application files to the builder stage
1717COPY ./web/Cargo.lock ./web/Cargo.toml ./web/dev-info.md ./web/index.html ./web/tailwind.config.js ./web/Trunk.toml /app/
1818COPY ./web/src /app/src
1919COPY ./web/static /app/static
2020WORKDIR /app
21- # Initialize trunk first
22- RUN cd /tmp && \
23- echo "" > dummy.rs && \
24- trunk build dummy.rs || true
25- RUN cargo install --locked wasm-bindgen-cli
2621# Build the Yew application in release mode
2722RUN RUSTFLAGS="--cfg=web_sys_unstable_apis --cfg getrandom_backend=\"wasm_js\"" trunk build --features server_build --release
2823
24+ # Go builder stage for the gpodder API
25+ FROM golang:alpine AS go-builder
26+ WORKDIR /gpodder-api
27+
28+ # Install build dependencies
29+ RUN apk add --no-cache git
30+
31+ # Copy go module files first for better layer caching
32+ COPY ./gpodder-api/go.mod ./gpodder-api/go.sum ./
33+ RUN go mod download
34+
35+ # Copy the rest of the source code
36+ COPY ./gpodder-api/cmd ./cmd
37+ COPY ./gpodder-api/config ./config
38+ COPY ./gpodder-api/internal ./internal
39+
40+ # Build the application
41+ RUN CGO_ENABLED=0 GOOS=linux go build -o gpodder-api ./cmd/server/
42+
2943# Python builder stage for database setup
3044FROM python:3.11-alpine AS python-builder
3145WORKDIR /build
@@ -59,64 +73,85 @@ RUN pyinstaller --onefile \
5973 --console \
6074 startup/setup_database_new.py
6175
76+ # Rust API builder stage
77+ FROM rust:alpine AS rust-api-builder
78+ WORKDIR /rust-api
79+
80+ # Install build dependencies
81+ RUN apk add --no-cache musl-dev pkgconfig openssl-dev openssl-libs-static
82+
83+ # Copy Rust API files
84+ COPY ./rust-api/Cargo.toml ./rust-api/Cargo.lock ./
85+ COPY ./rust-api/src ./src
86+
87+ # Set environment for static linking
88+ ENV OPENSSL_STATIC=1
89+ ENV OPENSSL_LIB_DIR=/usr/lib
90+ ENV OPENSSL_INCLUDE_DIR=/usr/include
91+
92+ # Build the Rust API
93+ RUN cargo build --release
94+
6295# Final stage for setting up runtime environment
6396FROM alpine
6497# Metadata
6598LABEL maintainer="Collin Pendleton <collinp@collinpendleton.com>"
6699
67- # Install runtime dependencies (removed Python)
68- RUN apk update && apk upgrade && \
69- apk add --no-cache nginx tzdata openssl bash mariadb-client curl ffmpeg supervisor wget jq && \
70- rm -rf /var/cache/apk/*
100+ # Install runtime dependencies
101+ RUN apk add --no-cache tzdata nginx openssl bash mariadb-client postgresql-client curl ffmpeg wget jq
102+
71103
72104# Download and install latest yt-dlp binary for ARM64
73105RUN LATEST_VERSION=$(curl -s https://api.github.com/repos/yt-dlp/yt-dlp/releases/latest | jq -r .tag_name) && \
74106 wget -O /usr/local/bin/yt-dlp "https://github.com/yt-dlp/yt-dlp/releases/download/${LATEST_VERSION}/yt-dlp_linux_aarch64" && \
75107 chmod +x /usr/local/bin/yt-dlp
76108
77- ENV TZ=UTC
78- # Set environment variables
79- ENV APP_ROOT=/pinepods
109+ # Download and install Horust (aarch64)
110+ RUN wget -O /tmp/horust.tar.gz "https://github.com/FedericoPonzi/Horust/releases/download/v0.1.7/horust-aarch64-unknown-linux-gnu.tar.gz" && \
111+ cd /tmp && tar -xzf horust.tar.gz && \
112+ mv horust /usr/local/bin/ && \
113+ chmod +x /usr/local/bin/horust && \
114+ rm -f /tmp/horust.tar.gz
80115
116+ ENV TZ=UTC
81117# Copy compiled database setup binary (replaces Python dependency)
82118COPY --from=python-builder /build/dist/pinepods-db-setup /usr/local/bin/
83-
84- # Copy wait-for-it script
85- COPY wait-for-it/wait-for-it.sh /wait-for-it.sh
86- RUN chmod +x /wait-for-it.sh
87-
88- # Copy built files from the builder stage
119+ # Copy built files from the builder stage to the Nginx serving directory
89120COPY --from=builder /app/dist /var/www/html/
90-
91- # Set up application directories and files
121+ # Copy Go API binary from the go-builder stage
122+ COPY --from=go-builder /gpodder-api/gpodder-api /usr/local/bin/
123+ # Copy Rust API binary from the rust-api-builder stage
124+ COPY --from=rust-api-builder /rust-api/target/release/pinepods-api /usr/local/bin/
125+ # Move to the root directory to execute the startup script
92126WORKDIR /
127+ # Copy startup scripts
93128COPY startup/startup.sh /startup.sh
94129RUN chmod +x /startup.sh
95-
96- RUN mkdir -p /pinepods /var/log/supervisor/
130+ # Copy Pinepods runtime files
131+ RUN mkdir -p /pinepods
132+ RUN mkdir -p /var/log/pinepods/ && mkdir -p /etc/horust/services/
97133COPY startup/ /pinepods/startup/
134+ # Legacy cron scripts removed - background tasks now handled by internal Rust scheduler
98135COPY clients/ /pinepods/clients/
99136COPY database_functions/ /pinepods/database_functions/
100- # Legacy cron scripts removed - background tasks now handled by internal Rust scheduler
101137RUN chmod +x /pinepods/startup/startup.sh
102-
103- # Clean things up
104- RUN rm -rf \
105- /var/cache/apk/* \
106- /root/.cache \
107- /tmp/* \
108- /var/tmp/* \
109- /usr/share/man \
110- /usr/share/doc
111-
112- # Define and set the version
138+ ENV APP_ROOT=/pinepods
139+ # Define the build argument
113140ARG PINEPODS_VERSION
141+ # Write the Pinepods version to the current_version file
114142RUN echo "${PINEPODS_VERSION}" > /pinepods/current_version
143+ # Configure Nginx
144+ COPY startup/nginx.conf /etc/nginx/nginx.conf
145+
146+ # Copy script to start gpodder API
147+ COPY ./gpodder-api/start-gpodder.sh /usr/local/bin/
148+ RUN chmod +x /usr/local/bin/start-gpodder.sh
115149
116150RUN cp /usr/share/zoneinfo/UTC /etc/localtime && \
117151 echo "UTC" > /etc/timezone
118152
119- # Configure Nginx
120- COPY startup/nginx.conf /etc/nginx/nginx.conf
153+ # Expose ports
154+ EXPOSE 8080 8000
121155
156+ # Start everything using the startup script
122157ENTRYPOINT ["bash", "/startup.sh"]
0 commit comments