diff --git a/.docker-compose.yml b/.docker-compose.yml index 686fd88..4461273 100644 --- a/.docker-compose.yml +++ b/.docker-compose.yml @@ -1,8 +1,12 @@ -version: '2' +version: "3.2" services: - lupt: - container_name: lupt-server + web: + container_name: lupt-chat build: . ports: - - "8080:8080" + - "8080:8081" + volumes: + - type: bind + source: ./etc + target: /app/lupt/etc diff --git a/.dockerignore b/.dockerignore index c41cc9e..1a9d661 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1 +1,2 @@ -/target \ No newline at end of file +/target +/etc diff --git a/.gitignore b/.gitignore index 4b8c433..1541106 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ /target -/config.json +/etc/config.json /localhost-key.pem /localhost.pem /docker-compose.yml diff --git a/Dockerfile b/Dockerfile index 5520e10..15333fd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,24 +1,29 @@ -FROM rust:1.58-alpine as builder +FROM rust:1-alpine3.16 -ENV PATH="/app/bin:${PATH}" +ENV APP=lupt -RUN mkdir -pv /app -COPY ./Cargo.toml /app -COPY ./Cargo.lock /app -COPY ./config.json /app -COPY ./run-lupt.sh /app/bin/run-lupt.sh -COPY ./src /app/src -COPY ./static /app/static +RUN cargo search --limit 0 -RUN apk upgrade --update-cache --available -RUN apk add musl-dev openssl-dev +RUN apk upgrade --update-cache --available && \ + apk add musl-dev && \ + apk add pkgconfig && \ + apk add openssl-dev && \ + rm -rf /var/cache/apk/* -WORKDIR /app +WORKDIR /app/${APP} +RUN mkdir /app/${APP}/etc -RUN cargo build -RUN cp -v target/debug/lupt bin +COPY . . + +RUN cargo build --release +RUN cp target/release/lupt . RUN cargo clean -RUN chmod 755 bin/run-lupt.sh +RUN /bin/sh -c 'export FILE=~/.cargo/registry/cache/; if [ -e $FILE ] ; then rm -rf $FILE ; fi' +RUN /bin/sh -c 'export FILE=~/.cargo/registry/src/; if [ -e $FILE ] ; then rm -rf $FILE ; fi' +RUN rm -rf /usr/local/rustup/ /usr/local/cargo/ +RUN apk del gcc -CMD ["run-lupt.sh"] +EXPOSE 8080/tcp + +CMD ["${APP}", "--bind_address", "0.0.0.0", "--port", "8080", "--config-file", "/app/${APP}/etc/config.json", "--static_path", "/app/${APP}/static/"] diff --git a/config.json.example b/etc/config.json.example similarity index 100% rename from config.json.example rename to etc/config.json.example diff --git a/run-lupt.sh b/run-lupt.sh deleted file mode 100644 index d2b024b..0000000 --- a/run-lupt.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh - -set -e - -echo => Starting lupt server -/app/bin/lupt --config-file /app/config.json --static_path /app/static --bind_address 0.0.0.0 --port 8080