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.
This commit is contained in:
33
Dockerfile
Normal file
33
Dockerfile
Normal file
@@ -0,0 +1,33 @@
|
||||
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"]
|
||||
Reference in New Issue
Block a user