-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathDockerfile
More file actions
72 lines (56 loc) · 2.13 KB
/
Dockerfile
File metadata and controls
72 lines (56 loc) · 2.13 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
64
65
66
67
68
69
70
71
72
# Build stage
FROM rust:1.91-slim-bookworm AS builder
# Install required system dependencies for building
RUN apt-get update && apt-get install -y \
pkg-config \
libssl-dev \
&& rm -rf /var/lib/apt/lists/*
# Set working directory
WORKDIR /app
# Copy manifests first for better layer caching
COPY Cargo.toml Cargo.lock build.rs ./
ARG FEATURES=embed,postgres
ARG TEMPLATES=./templates
ARG STATIC=./static
ARG GIT_HASH=0
ENV GIT_HASH=$GIT_HASH
# Copy actual source code and assets
COPY src ./src
COPY migrations ./migrations
COPY ${TEMPLATES} ./templates
COPY ${STATIC} ./static
ENV HTTP_TEMPLATE_PATH=/app/templates/
# Build the actual application with embed feature only
RUN cargo build --release --bin aip --no-default-features --features ${FEATURES}
# Build the client management CLI
RUN cargo build --release --bin aip-client-management --no-default-features --features ${FEATURES}
# Add the sqlx cli for running migrations in containers
RUN cargo install sqlx-cli --root /app/.cargo --no-default-features --features native-tls,postgres
# Runtime stage using distroless
FROM gcr.io/distroless/cc-debian12
# Add OCI labels
LABEL org.opencontainers.image.title="aip"
LABEL org.opencontainers.image.description="ATProtocol Identity Provider - OAuth 2.1 authorization server with ATProtocol integration"
LABEL org.opencontainers.image.version="0.1.0"
LABEL org.opencontainers.image.authors="Graze Social"
LABEL org.opencontainers.image.licenses="MIT"
# Build time will be set during image build
# Set working directory
WORKDIR /app
# Copy the binary from builder stage
COPY --from=builder /app/target/release/aip /app/aip
# Copy the client management binary from builder stage
COPY --from=builder /app/target/release/aip-client-management /app/aip-client-management
# Copy static directory
COPY --from=builder /app/static ./static
# Copy migrations directory
COPY --from=builder /app/migrations ./migrations
# Copy sqlx binary for running migrations
COPY --from=builder /app/.cargo/bin/sqlx /app/sqlx
# Set default environment variables
ENV HTTP_STATIC_PATH=/app/static
ENV HTTP_PORT=8080
# Expose port
EXPOSE 8080
# Run the application
CMD ["/app/aip"]