-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
64 lines (50 loc) · 1.6 KB
/
Copy pathDockerfile
File metadata and controls
64 lines (50 loc) · 1.6 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
56
57
58
59
60
61
62
63
# Multi-stage build for Dioxus web app
# Stage 1: Build the application
FROM rust:1.83-bookworm as builder
# Install system dependencies
RUN apt-get update && apt-get install -y \
pkg-config \
libssl-dev \
&& rm -rf /var/lib/apt/lists/*
# Install Dioxus CLI
RUN cargo install dioxus-cli
# Set working directory
WORKDIR /app
# Copy manifests first for better layer caching
COPY Cargo.toml Cargo.lock ./
COPY Dioxus.toml ./
# Copy source code and assets
COPY src ./src
COPY assets ./assets
COPY words.yaml ./words.yaml
# Create public directory if needed
RUN mkdir -p public
# Build the web application in release mode
# This generates static files in the dist/ directory
RUN dx build --platform web --release
# Stage 2: Serve the application
FROM nginx:alpine
# Copy the built assets from builder stage
COPY --from=builder /app/dist /usr/share/nginx/html
# Copy custom nginx configuration (optional, creates a basic one)
RUN echo 'server { \
listen 80; \
server_name _; \
root /usr/share/nginx/html; \
index index.html; \
location / { \
try_files $uri $uri/ /index.html; \
} \
# Enable gzip compression \
gzip on; \
gzip_vary on; \
gzip_min_length 1024; \
gzip_types text/plain text/css text/xml text/javascript application/javascript application/xml+rss application/json application/wasm; \
}' > /etc/nginx/conf.d/default.conf
# Expose port 80
EXPOSE 80
# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD wget --quiet --tries=1 --spider http://localhost/ || exit 1
# Start nginx
CMD ["nginx", "-g", "daemon off;"]