commit 86d8fd16c835b776396ac4563a0a86efbbd82480 Author: Dmitry Date: Tue Aug 20 16:15:55 2019 +0300 initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e3503ee --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/db diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..a6cf1f2 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "src"] + path = src + url = ssh://git@gitea.b4tman.ru:4222/b4tman/qchgk_web.git diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..4c92529 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,27 @@ +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 + +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/alpine.Dockerfile b/alpine.Dockerfile new file mode 100644 index 0000000..d4690dc --- /dev/null +++ b/alpine.Dockerfile @@ -0,0 +1,39 @@ +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 new file mode 100644 index 0000000..d659223 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,25 @@ +version: '2' +services: + qchgk: + build: + context: src + dockerfile: ../stable.Dockerfile +# dockerfile: ../nightly.Dockerfile + image: 'b4tman/qchgk:actix' +# image: 'b4tman/qchgk:rocket' + container_name: 'qchgk' + ports: + - '8088:8088' + logging: + driver: json-file + options: + max-file: '5' + max-size: 10m + environment: + ROCKET_ENV: prod + ROCKET_PORT: 8088 +# RUST_BACKTRACE: 1 +# RUST_BACKTRACE: full + volumes: + - '/data/lab/docker/qchgk_web/db:/db/:ro' + diff --git a/nightly.Dockerfile b/nightly.Dockerfile new file mode 100644 index 0000000..52e7bf6 --- /dev/null +++ b/nightly.Dockerfile @@ -0,0 +1,30 @@ +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/src b/src new file mode 160000 index 0000000..665bbaa --- /dev/null +++ b/src @@ -0,0 +1 @@ +Subproject commit 665bbaadfb80c2b0fa7679ffea426107873e5894 diff --git a/stable.Dockerfile b/stable.Dockerfile new file mode 100644 index 0000000..7740a81 --- /dev/null +++ b/stable.Dockerfile @@ -0,0 +1,30 @@ +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"]