Skip to content

Commit

Permalink
dockerize rust newsletter
Browse files Browse the repository at this point in the history
  • Loading branch information
dibakarsutradhar committed Apr 20, 2024
1 parent c533f9b commit b1dd619
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
19 changes: 19 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# We use the latest Rust stable release as base image
FROM rust:1.77.2 as builder

WORKDIR /app
# Install the required system dependencies for our linking configuration
# Copy all files from our working environments to our Docker image
# Build binary!
# Using release profile to make it fast
RUN apt update && apt install lld clang -y && \
COPY . . && \
ENV SQLX_OFFLINE true && \
cargo build --release

# Use a smaller base image for the final image
FROM debian:buster-slim
WORKDIR /app
COPY --from=builder /app/target/release/newsletter /app/newsletter
# When `docker run` is executed, launch the binary!
ENTRYPOINT [ "./newsletter" ]
10 changes: 10 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: '3.8'
services:
newsletter:
build:
context: .
dockerfile: Dockerfile
volumes:
- .:/app
ports:
- "8000:8000"

0 comments on commit b1dd619

Please sign in to comment.