Actix-Demo/build.Dockerfile

43 lines
932 B
Docker
Raw Normal View History

2021-04-21 10:18:58 +00:00
FROM rust:1.51 as builder
# ENV CARGO_HOME=/actix-demo/.cargo
RUN USER=root cargo new --bin actix-demo
WORKDIR /actix-demo
2021-04-23 17:31:14 +00:00
# COPY ./.cargo ./.cargo
COPY ./Cargo.toml ./Cargo.toml
COPY ./Cargo.lock ./Cargo.lock
RUN cargo build --release
2021-04-23 17:31:14 +00:00
RUN rm -r src/*.rs
COPY ./src ./src
2021-04-23 17:31:14 +00:00
RUN rm ./target/release/deps/actix_demo*
RUN cargo build --release
FROM debian:buster-slim
ARG APP=/usr/src/app
RUN apt-get update \
&& apt-get install -y ca-certificates tzdata \
&& rm -rf /var/lib/apt/lists/*
EXPOSE 8000
ENV TZ=Etc/UTC \
APP_USER=appuser
RUN groupadd $APP_USER \
&& useradd -g $APP_USER $APP_USER \
&& mkdir -p ${APP}
COPY ./.env ${APP}/.env
COPY ./migrations ${APP}/migrations
COPY ./static ${APP}/static
2021-04-27 11:22:27 +00:00
COPY ./db/empty.db ${APP}/data/app.db
COPY --from=builder /actix-demo/target/release/actix-demo ${APP}/actix-demo
RUN chown -R $APP_USER:$APP_USER ${APP}
USER $APP_USER
WORKDIR ${APP}
CMD ["./actix-demo"]