Skip to content

Commit 3e187ba

Browse files
authored
Merge pull request #1224 from kenkoooo/feat/simplified-dockerfile
simplifiy Dockerfile
2 parents 40f5a26 + c950511 commit 3e187ba

File tree

1 file changed

+11
-23
lines changed

1 file changed

+11
-23
lines changed

atcoder-problems-backend/Dockerfile

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,23 @@ FROM rust:1.57.0 AS development
22
RUN rustup component add rustfmt
33
RUN rustup component add clippy
44

5-
FROM rust:1.57.0 AS builder
6-
5+
# Using the official cargo-chef image
6+
FROM lukemathwalker/cargo-chef:latest-rust-1.61.0 AS chef
77
WORKDIR /app
88

9-
# Configure sql-client
10-
RUN mkdir -p ./sql-client/src
11-
RUN touch ./sql-client/src/lib.rs
12-
ADD ./sql-client/Cargo.toml ./sql-client
13-
14-
# Configure atcoder-client
15-
RUN mkdir -p ./atcoder-client/src
16-
RUN touch ./atcoder-client/src/lib.rs
17-
ADD ./atcoder-client/Cargo.toml ./atcoder-client
9+
FROM chef AS planner
10+
COPY . .
11+
RUN cargo chef prepare --recipe-path recipe.json
1812

19-
RUN mkdir ./src
20-
RUN echo "fn main(){}" > ./src/main.rs
21-
ADD ./Cargo.toml .
22-
ADD ./Cargo.lock .
13+
FROM chef AS builder
14+
COPY --from=planner /app/recipe.json recipe.json
15+
RUN cargo chef cook --release --recipe-path recipe.json
2316

17+
COPY . .
2418
RUN cargo build --release
2519

26-
ADD ./src ./src
27-
ADD ./sql-client ./sql-client
28-
ADD ./atcoder-client ./atcoder-client
29-
RUN cargo clean --release -p atcoder-client -p sql-client
30-
RUN cargo build --release
31-
32-
FROM rust:1.57.0 AS production
20+
# プロダクション用の Docker イメージをビルドする
21+
FROM rust:1.61.0 AS production
3322
COPY --from=builder /app/target/release/batch_update /usr/bin/batch_update
3423
COPY --from=builder /app/target/release/crawl_all_submissions /usr/bin/crawl_all_submissions
3524
COPY --from=builder /app/target/release/crawl_for_virtual_contests /usr/bin/crawl_for_virtual_contests
@@ -42,6 +31,5 @@ COPY --from=builder /app/target/release/dump_json /usr/bin/dum
4231
COPY --from=builder /app/target/release/fix_invalid_submissions /usr/bin/fix_invalid_submissions
4332
COPY --from=builder /app/target/release/run_server /usr/bin/run_server
4433

45-
4634
RUN apt-get update && apt-get install -y awscli postgresql-client
4735
ADD ./scripts/sql-backup.sh /usr/bin/sql-backup.sh

0 commit comments

Comments
 (0)