-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
35 lines (33 loc) · 927 Bytes
/
Dockerfile
File metadata and controls
35 lines (33 loc) · 927 Bytes
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
# Build the React frontend
FROM node:20 as frontend-builder
WORKDIR /app
COPY frontend/package.json frontend/package-lock.json* ./
RUN npm install
COPY frontend/ ./
RUN npm run build
# Build the Rust backend
FROM rust:1.87 as backend-builder
WORKDIR /app
COPY Cargo.toml Cargo.lock ./
# Create dummy src to cache dependencies
RUN mkdir src && echo "fn main() {}" > src/main.rs
RUN cargo build --release
# Remove the dummy files
RUN rm -rf src
# Copy the actual source code
COPY src ./src
# Build the actual application
RUN touch src/main.rs && cargo build --release
# Final image
FROM rust:1.87-slim
WORKDIR /app
# Copy the built backend binary
COPY --from=backend-builder /app/target/release/slackwatch /app/
# Copy the built frontend assets
COPY --from=frontend-builder /app/dist /app/frontend/dist
# Copy assets if needed
COPY assets /app/assets
# Expose the port
EXPOSE 8080
# Run the application
CMD ["/app/slackwatch"]