feat(api): containerization

- Build SQLx queries beforehand so that we don't have to do PostgreSQL
init right away at service start up
- Created `Dockerfile.production`
- Updated docs
- Seperate configuration files for local and development environments
This commit is contained in:
2024-05-10 19:38:07 -04:00
parent 7b5fa61780
commit daf914bb8e
9 changed files with 119 additions and 12 deletions

20
Dockerfile.production Normal file
View File

@@ -0,0 +1,20 @@
# We use the latest Rust stable release as base image
FROM rust:1.78.0
# Let's switch our working directory to `app` (equivalent to `cd app`)
# The `app` folder will be created for us by Docker in case it does not
# exist already.
WORKDIR /app
# Install the required system dependencies for our linking configuration
RUN apt update && apt install lld clang -y
# Copy all files from our working environment to our Docker image
COPY . .
# Let's build our binary!
# We'll use the release profile to make it faaaast
ENV SQLX_OFFLINE true
RUN cargo build --release
ENV APP_ENVIRONMENT production
# When `docker run` is executed, launch the binary!
ENTRYPOINT ["./target/release/email_newsletter_api"]