Files
hospitalapi/Dockerfile
Ben Melchior a70c80a557 Add Docker support with Dockerfile and docker-compose.yml
- Introduced a Dockerfile for building the application using a multi-stage build process.
- Added docker-compose.yml to define services for the application and PostgreSQL database.
- Updated README.md with instructions for running the application using Docker and Docker Compose.
2025-04-15 20:26:06 +02:00

33 lines
704 B
Docker

FROM rust:1.76-slim-bullseye as builder
WORKDIR /usr/src/app
COPY . .
# Build the application
RUN cargo build --release
# Create a new stage with a minimal image
FROM debian:bullseye-slim
WORKDIR /usr/local/bin
# Install necessary runtime dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# Copy the built binary from the builder stage
COPY --from=builder /usr/src/app/target/release/hospitalapi .
# Create a directory for the .env file
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
# Copy the .env file
COPY .env .
# Expose the port the app runs on
EXPOSE 3000
# Run the application
CMD ["./hospitalapi"]