Skip to content

Commit dfc3e58

Browse files
committed
Update docker script
1 parent a6efe7a commit dfc3e58

File tree

1 file changed

+16
-18
lines changed

1 file changed

+16
-18
lines changed

Dockerfile

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,44 @@
11
# build stage
2-
FROM rustlang/rust:nightly-slim as build
2+
FROM rust:slim as build
33

4-
# install libpq
5-
RUN apt-get update
6-
RUN apt-get install -y libpq-dev
7-
RUN rm -rf /var/lib/apt/lists/*
8-
9-
# create new empty binary project
10-
RUN USER=root cargo new --bin app
4+
# install libpq and create new empty binary project
5+
RUN apt-get update; \
6+
apt-get install --no-install-recommends -y libpq-dev; \
7+
rm -rf /var/lib/apt/lists/*; \
8+
USER=root cargo new --bin app
119
WORKDIR /app
1210

1311
# copy manifests
1412
COPY ./Cargo.toml ./Cargo.toml
1513

1614
# build this project to cache dependencies
17-
RUN cargo build --release
18-
RUN rm src/*.rs
15+
RUN cargo build --release; \
16+
rm src/*.rs
1917

2018
# copy project source and necessary files
2119
COPY ./src ./src
2220
COPY ./migrations ./migrations
2321
COPY ./diesel.toml .
2422

2523
# add .env and secret.key for Docker env
26-
RUN touch .env
27-
RUN mv src/secret.key.sample src/secret.key
24+
RUN touch .env; \
25+
mv src/secret.key.sample src/secret.key
2826

2927
# rebuild app with project source
30-
RUN rm ./target/release/deps/actix_web_rest_api_with_jwt*
31-
RUN cargo build --release
28+
RUN rm ./target/release/deps/actix_web_rest_api_with_jwt*; \
29+
cargo build --release
3230

3331
# deploy stage
34-
FROM debian:stretch-slim
32+
FROM debian:buster-slim
3533

3634
# create app directory
3735
RUN mkdir app
3836
WORKDIR /app
3937

4038
# install libpq
41-
RUN apt-get update
42-
RUN apt-get install -y libpq-dev
43-
RUN rm -rf /var/lib/apt/lists/*
39+
RUN apt-get update; \
40+
apt-get install --no-install-recommends -y libpq-dev; \
41+
rm -rf /var/lib/apt/lists/*
4442

4543
# copy binary and configuration files
4644
COPY --from=build /app/target/release/actix-web-rest-api-with-jwt .

0 commit comments

Comments
 (0)