-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
51 lines (35 loc) · 1.07 KB
/
Dockerfile
File metadata and controls
51 lines (35 loc) · 1.07 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
# Build stage
FROM rust:1.92-alpine AS builder
# Install build dependencies
RUN apk add --no-cache musl-dev openssl-dev openssl-libs-static
WORKDIR /app
# Copy manifests
COPY Cargo.toml Cargo.lock ./
# Copy source code
COPY src ./src
# Copy SQLX offline data (if exists) to enable builds without database
COPY .sqlx/ .sqlx/
# Build the application in release mode with SQLX offline mode
ENV SQLX_OFFLINE=true
RUN cargo build --release
# Runtime stage
FROM alpine:3.20
# Install runtime dependencies
RUN apk add --no-cache ca-certificates libgcc openssl-libs-static
# Create a non-root user
RUN addgroup -g 1000 appuser && \
adduser -D -u 1000 -G appuser appuser
WORKDIR /app
# Copy the binary from builder
COPY --from=builder /app/target/release/texture-provider2 /app/texture-provider2
# Create uploads directory for local storage
RUN mkdir -p /app/uploads && \
chown -R appuser:appuser /app
# Switch to non-root user
USER appuser
# Expose the default port
EXPOSE 3000
# Set environment defaults
ENV SERVER_PORT=3000
# Run the application
CMD ["./texture-provider2"]