docker compose file #1

closed
opened by teal.fm targeting master from docker
+43
Dockerfile
···
+
# Use the official Rust image
+
FROM rust:1.75-slim as builder
+
+
# Set working directory
+
WORKDIR /app
+
+
# Copy manifest files
+
COPY Cargo.toml Cargo.lock ./
+
+
# Copy source code
+
COPY src ./src
+
+
# Build the application
+
RUN cargo build --release
+
+
# Runtime stage
+
FROM debian:bookworm-slim
+
+
# Install runtime dependencies
+
RUN apt-get update && apt-get install -y \
+
ca-certificates \
+
&& rm -rf /var/lib/apt/lists/*
+
+
# Create app user
+
RUN useradd -r -s /bin/false appuser
+
+
# Set working directory
+
WORKDIR /app
+
+
# Copy the binary from builder stage
+
COPY --from=builder /app/target/release/discordhose /app/discordhose
+
+
# Change ownership to app user
+
RUN chown -R appuser:appuser /app
+
+
# Switch to app user
+
USER appuser
+
+
# Expose port (if needed in the future)
+
EXPOSE 8080
+
+
# Run the application
+
CMD ["./discordhose"]
+12
docker-compose.yml
···
+
version: "3.8"
+
+
services:
+
discordhose:
+
build: .
+
environment:
+
- DISCORD_WEBHOOK_URL=${DISCORD_WEBHOOK_URL}
+
env_file:
+
- .env
+
restart: unless-stopped
+
volumes:
+
- ./.env:/app/.env:ro