Skip to content

Commit

Permalink
Merge branch 'master' into config/appveyor
Browse files Browse the repository at this point in the history
  • Loading branch information
thibault-cne authored Apr 21, 2024
2 parents 0ee4143 + 573eb8a commit 759478e
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 6 deletions.
55 changes: 55 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
FROM rust:alpine3.19 AS chef

RUN apk add --no-cache musl-dev

RUN cargo install cargo-chef

WORKDIR /usr
RUN cargo new --bin purple-sector
WORKDIR /usr/purple-sector
COPY Cargo.toml Cargo.lock ./

# Create the all architecture tree
RUN mkdir bin
RUN mkdir crates
RUN cargo new --bin bin/api
RUN cargo new --lib crates/api
RUN cargo new --lib crates/application
RUN cargo new --lib crates/derives
RUN cargo new --lib crates/infrastructure
RUN cargo new --lib crates/shared
RUN cargo new --lib crates/logger

# Copy the Cargo.toml files
COPY bin/api/Cargo.toml bin/api/Cargo.toml
COPY crates/api/Cargo.toml crates/api/Cargo.toml
COPY crates/application/Cargo.toml crates/application/Cargo.toml
COPY crates/derives/Cargo.toml crates/derives/Cargo.toml
COPY crates/infrastructure/Cargo.toml crates/infrastructure/Cargo.toml
COPY crates/shared/Cargo.toml crates/shared/Cargo.toml
COPY crates/logger/Cargo.toml crates/logger/Cargo.toml

FROM chef AS planner

RUN cargo chef prepare --recipe-path recipe.json

FROM planner AS builder

COPY --from=planner /usr/purple-sector/recipe.json recipe.json
# Build dependencies - this is the caching Docker layer!
RUN cargo chef cook --recipe-path recipe.json

RUN rm -rf src bin/* crates/*

COPY bin bin
COPY crates crates

RUN cargo build --release

FROM alpine:3.19 AS runtime

LABEL maintainer="Thibault C. <thibault.chene23@gmail.com>"

COPY --from=builder /usr/purple-sector/target/release/purple-sector /usr/local/bin

CMD ["/usr/local/bin/purple-sector"]
4 changes: 2 additions & 2 deletions config.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
---
database:
name: f1db
hostname: 127.0.0.1
hostname: database
port: 3306
user: user
password: password

cache:
hostname: 127.0.0.1
hostname: dragonfly
port: 6379

middlewares:
Expand Down
29 changes: 25 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,38 @@ services:
MYSQL_DATABASE: ${MYSQL_DATABASE}
MYSQL_USER: ${MYSQL_USER}
MYSQL_PASSWORD: ${MYSQL_PASSWORD}
ports:
- "3306:3306"
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "localhost"]
timeout: 20s
retries: 10

dragonfly:
image: docker.dragonflydb.io/dragonflydb/dragonfly:v1.16.1
ulimits:
memlock: -1
ports:
- "6379:6379"
volumes:
- dragonflydata:/data
healthcheck:
test: ["CMD", "redis-cli", "--raw", "incr", "ping"]
timeout: 20s
retries: 10

api:
build:
context: .
ports:
- "8000:8000"
volumes:
- ./config.yml:/config.yml
depends_on:
database:
condition: service_healthy
dragonfly:
condition: service_healthy

volumes:
dragonflydata:

networks:
default:
driver: bridge

0 comments on commit 759478e

Please sign in to comment.