From 025c58adac560991f518a22888c539f7e338d431 Mon Sep 17 00:00:00 2001 From: Dmitry Date: Tue, 20 Aug 2019 16:24:39 +0300 Subject: [PATCH] one Dockerfile --- Dockerfile | 9 ++++++--- alpine.Dockerfile | 39 --------------------------------------- docker-compose.yml | 3 +-- nightly.Dockerfile | 30 ------------------------------ stable.Dockerfile | 30 ------------------------------ 5 files changed, 7 insertions(+), 104 deletions(-) delete mode 100644 alpine.Dockerfile delete mode 100644 nightly.Dockerfile delete mode 100644 stable.Dockerfile diff --git a/Dockerfile b/Dockerfile index 4c92529..52e7bf6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,16 +1,19 @@ -FROM ekidd/rust-musl-builder:1.36.0 as builder +FROM ekidd/rust-musl-builder:nightly-2019-07-08 as builder COPY Cargo.toml /home/rust/src/ COPY Cargo.lock /home/rust/src/ -RUN mkdir /home/rust/src/src && touch /home/rust/src/src/main.rs +RUN mkdir /home/rust/src/src && \ + echo 'fn main() {}' > /home/rust/src/src/main.rs RUN sudo chown -R rust:rust . RUN cargo fetch -RUN cargo build --release || true +RUN cargo build --release RUN rm -f /home/rust/src/src/main.rs COPY src /home/rust/src/src +RUN sudo chown -R rust:rust . && \ + touch /home/rust/src/src/main.rs RUN cargo build --release diff --git a/alpine.Dockerfile b/alpine.Dockerfile deleted file mode 100644 index d4690dc..0000000 --- a/alpine.Dockerfile +++ /dev/null @@ -1,39 +0,0 @@ -FROM ekidd/rust-musl-builder:1.36.0 as builder - -COPY Cargo.toml /home/rust/src/ -COPY Cargo.lock /home/rust/src/ -RUN mkdir /home/rust/src/src && touch /home/rust/src/src/main.rs - -RUN sudo chown -R rust:rust . - -RUN cargo fetch -RUN cargo build --release || true - -RUN rm -f /home/rust/src/src/main.rs -COPY src /home/rust/src/src - -#COPY pre-main.rs /home/rust/src -#COPY add-Cargo.toml /home/rust/src\ -#RUN mv /home/rust/src/src/main.rs /home/rust/src/tmp-main.rs &&\ -# cat /home/rust/src/pre-main.rs > /home/rust/src/src/main.rs &&\ -# cat /home/rust/src/tmp-main.rs >> /home/rust/src/src/main.rs &&\ -# echo >> /home/rust/src/Cargo.toml &&\ -# cat /home/rust/src/add-Cargo.toml >> /home/rust/src/Cargo.toml - -#RUN sudo apt-get update && sudo apt-get install -y autogen automake git make - -RUN cargo build --release - -FROM alpine:3.10 - -RUN mkdir /app -COPY static /app/static -COPY templates /app/templates -COPY --from=builder /home/rust/src/target/x86_64-unknown-linux-musl/release/qchgk_web /app/qchgk_web -RUN ls -lsha /app/qchgk_web - -WORKDIR /app - -EXPOSE 8088/tcp - -CMD /app/qchgk_web diff --git a/docker-compose.yml b/docker-compose.yml index 0ba6e93..c20f23e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,7 +3,7 @@ services: qchgk: build: context: src - dockerfile: ../nightly.Dockerfile + dockerfile: ../Dockerfile image: 'b4tman/qchgk:rocket' container_name: 'qchgk' ports: @@ -20,4 +20,3 @@ services: # RUST_BACKTRACE: full volumes: - '/data/lab/docker/qchgk_web/db:/db/:ro' - diff --git a/nightly.Dockerfile b/nightly.Dockerfile deleted file mode 100644 index 52e7bf6..0000000 --- a/nightly.Dockerfile +++ /dev/null @@ -1,30 +0,0 @@ -FROM ekidd/rust-musl-builder:nightly-2019-07-08 as builder - -COPY Cargo.toml /home/rust/src/ -COPY Cargo.lock /home/rust/src/ -RUN mkdir /home/rust/src/src && \ - echo 'fn main() {}' > /home/rust/src/src/main.rs - -RUN sudo chown -R rust:rust . - -RUN cargo fetch -RUN cargo build --release - -RUN rm -f /home/rust/src/src/main.rs -COPY src /home/rust/src/src -RUN sudo chown -R rust:rust . && \ - touch /home/rust/src/src/main.rs - -RUN cargo build --release - -FROM scratch - -COPY static /static -COPY templates /templates -COPY --from=builder /home/rust/src/target/x86_64-unknown-linux-musl/release/qchgk_web / - -VOLUME /db - -EXPOSE 8088/tcp - -ENTRYPOINT ["/qchgk_web"] diff --git a/stable.Dockerfile b/stable.Dockerfile deleted file mode 100644 index 7740a81..0000000 --- a/stable.Dockerfile +++ /dev/null @@ -1,30 +0,0 @@ -FROM ekidd/rust-musl-builder:1.36.0 as builder - -COPY Cargo.toml /home/rust/src/ -COPY Cargo.lock /home/rust/src/ -RUN mkdir /home/rust/src/src && \ - echo 'fn main() {}' > /home/rust/src/src/main.rs - -RUN sudo chown -R rust:rust /home/rust/src/ - -RUN cargo fetch -RUN cargo build --release - -RUN rm -f /home/rust/src/src/main.rs -COPY src /home/rust/src/src -RUN sudo chown -R rust:rust /home/rust/src/ && \ - touch /home/rust/src/src/main.rs - -RUN cargo build --release - -FROM scratch - -COPY static /static -COPY templates /templates -COPY --from=builder /home/rust/src/target/x86_64-unknown-linux-musl/release/qchgk_web / - -VOLUME /db - -EXPOSE 8088/tcp - -ENTRYPOINT ["/qchgk_web"]