-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
70 lines (55 loc) · 1.91 KB
/
Dockerfile
File metadata and controls
70 lines (55 loc) · 1.91 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
# Dockerfile multi-stage para build otimizado
# ============================================================
# Stage 1: Build do Frontend (TEMPORARIAMENTE DESABILITADO)
# ============================================================
# FROM node:20-alpine AS frontend-builder
#
# WORKDIR /app/frontend
#
# # Copiar apenas package files para cache de dependências
# COPY frontend/package*.json ./
# RUN npm ci
#
# # Copiar código fonte e buildar
# COPY frontend/ ./
# RUN npm run build
# ============================================================
# Stage 2: Build do Backend (Rust)
# ============================================================
FROM rust:latest AS backend-builder
# Instalar dependências de sistema
RUN apt-get update && apt-get install -y \
pkg-config \
libssl-dev \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Copiar Cargo files para cache de dependências
COPY Cargo.toml build.rs ./
COPY src/ ./src/
# Build em release mode
RUN cargo build --release --bin geolocation-server
# ============================================================
# Stage 3: Imagem final (runtime leve)
# ============================================================
FROM debian:bookworm-slim
# Instalar apenas dependências de runtime
RUN apt-get update && apt-get install -y \
ca-certificates \
curl \
libssl3 \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Copiar binário compilado do backend
COPY --from=backend-builder /app/target/release/geolocation-server ./geolocation-server
# Copiar frontend buildado (TEMPORARIAMENTE DESABILITADO)
# COPY --from=frontend-builder /app/frontend/dist ./frontend/dist
# Variáveis de ambiente (atualizadas para MongoDB)
ENV RUST_LOG=info
ENV PORT=8080
# Expor porta
EXPOSE 8080
# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD curl -f http://localhost:8080/api/health || exit 1
# Executar servidor
CMD ["./geolocation-server"]