dockerfile for building release app
This commit is contained in:
37
.dockerignore
Normal file
37
.dockerignore
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
# Rust build artifacts
|
||||||
|
/target
|
||||||
|
**/*.rs.bk
|
||||||
|
|
||||||
|
# Development environment
|
||||||
|
.env
|
||||||
|
.devcontainer
|
||||||
|
.vscode
|
||||||
|
.idea
|
||||||
|
*.swp
|
||||||
|
*.swo
|
||||||
|
|
||||||
|
# Git
|
||||||
|
.git
|
||||||
|
.gitignore
|
||||||
|
.github
|
||||||
|
|
||||||
|
# Documentation and misc
|
||||||
|
README.md
|
||||||
|
LICENSE
|
||||||
|
*.md
|
||||||
|
|
||||||
|
# Generated files
|
||||||
|
embeddings_visualization.html
|
||||||
|
|
||||||
|
# Debug files
|
||||||
|
core
|
||||||
|
*.log
|
||||||
|
|
||||||
|
# Docker files (except Dockerfile which we need)
|
||||||
|
.dockerignore
|
||||||
|
docker-compose*.yml
|
||||||
|
|
||||||
|
# Temporary files
|
||||||
|
*.tmp
|
||||||
|
*.temp
|
||||||
|
*~
|
||||||
9
.env.example
Normal file
9
.env.example
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
# PostgreSQL connection settings
|
||||||
|
POSTGRES_HOST=postgres
|
||||||
|
POSTGRES_PORT=5432
|
||||||
|
POSTGRES_DB=postgres
|
||||||
|
POSTGRES_USER=postgres
|
||||||
|
POSTGRES_PASSWORD=changeme
|
||||||
|
|
||||||
|
# Logging level (debug, info, warn, error)
|
||||||
|
RUST_LOG=info
|
||||||
59
Dockerfile
Normal file
59
Dockerfile
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
FROM rust:1.75-slim-bullseye as builder
|
||||||
|
|
||||||
|
# Install build dependencies
|
||||||
|
RUN apt-get update && \
|
||||||
|
apt-get install -y \
|
||||||
|
pkg-config \
|
||||||
|
libssl-dev \
|
||||||
|
libpq-dev \
|
||||||
|
gcc \
|
||||||
|
g++ \
|
||||||
|
make \
|
||||||
|
clang \
|
||||||
|
lld \
|
||||||
|
libomp-dev \
|
||||||
|
libopenblas-dev \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
# Create a new empty project
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Create a dummy project to cache dependencies
|
||||||
|
COPY Cargo.toml Cargo.lock ./
|
||||||
|
RUN mkdir src && \
|
||||||
|
echo "fn main() {println!(\"dummy\")}" > src/main.rs && \
|
||||||
|
cargo build --release && \
|
||||||
|
rm -rf src
|
||||||
|
|
||||||
|
# Now copy the real source code
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
# Build the application in release mode with cargo cache
|
||||||
|
RUN --mount=type=cache,target=/usr/local/cargo/registry \
|
||||||
|
--mount=type=cache,target=/app/target \
|
||||||
|
cargo build --release && \
|
||||||
|
cp target/release/mf-fitter /app/mf-fitter
|
||||||
|
|
||||||
|
# Create the runtime image
|
||||||
|
FROM debian:bullseye-slim
|
||||||
|
|
||||||
|
# Install runtime dependencies
|
||||||
|
RUN apt-get update && \
|
||||||
|
apt-get install -y \
|
||||||
|
libpq5 \
|
||||||
|
ca-certificates \
|
||||||
|
libomp5 \
|
||||||
|
libopenblas0 \
|
||||||
|
libgomp1 \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
# Copy the binary from builder
|
||||||
|
COPY --from=builder /app/mf-fitter /usr/local/bin/
|
||||||
|
COPY --from=builder /app/.env.example /app/.env
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Set environment variables
|
||||||
|
ENV RUST_LOG=info
|
||||||
|
|
||||||
|
ENTRYPOINT ["/usr/local/bin/mf-fitter"]
|
||||||
Reference in New Issue
Block a user