diff --git a/.gitignore b/.gitignore index 19d820c..8946455 100644 --- a/.gitignore +++ b/.gitignore @@ -8,4 +8,5 @@ certs/* echoer .env.private *.lock -static/ \ No newline at end of file +static/ +.vscode/ \ No newline at end of file diff --git a/images/integration-tests/tests_runner.Dockerfile b/images/integration-tests/tests_runner.Dockerfile index 2411bd6..4bf8287 100644 --- a/images/integration-tests/tests_runner.Dockerfile +++ b/images/integration-tests/tests_runner.Dockerfile @@ -1,4 +1,4 @@ -FROM rust:1.53 +FROM rust:1.55 RUN rustup target add x86_64-unknown-linux-musl CMD ["sleep", "3600"] \ No newline at end of file diff --git a/images/integration-tests/u_db.Dockerfile b/images/integration-tests/u_db.Dockerfile index 8577c8d..783d887 100644 --- a/images/integration-tests/u_db.Dockerfile +++ b/images/integration-tests/u_db.Dockerfile @@ -1,3 +1,11 @@ FROM postgres:13.3 -RUN apt update && apt -y upgrade && apt install -y iproute2 \ No newline at end of file +RUN apt update && apt upgrade -y +RUN apt install -y curl build-essential libpq-dev iproute2 +RUN curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain stable --profile minimal +ENV PATH /root/.cargo/bin:$PATH +RUN rustup target add x86_64-unknown-linux-musl +RUN cargo install diesel_cli --no-default-features --features postgres + +RUN mkdir -p /unki +COPY u_db_entrypoint.sh /unki/ \ No newline at end of file diff --git a/images/integration-tests/u_db_entrypoint.sh b/images/integration-tests/u_db_entrypoint.sh new file mode 100755 index 0000000..e67acc1 --- /dev/null +++ b/images/integration-tests/u_db_entrypoint.sh @@ -0,0 +1,5 @@ +set -m + +export DATABASE_URL=postgres://${DB_USER}:${DB_PASSWORD}@127.0.0.1/${DB_NAME} +/usr/local/bin/docker-entrypoint.sh postgres & +sleep 10 && diesel setup && fg %1 \ No newline at end of file diff --git a/images/integration-tests/u_server.Dockerfile b/images/integration-tests/u_server.Dockerfile index ea82ccd..691a618 100644 --- a/images/integration-tests/u_server.Dockerfile +++ b/images/integration-tests/u_server.Dockerfile @@ -1,3 +1,3 @@ -FROM rust:1.53 +FROM alpine:latest -RUN cargo install diesel_cli --no-default-features --features postgres \ No newline at end of file +RUN apk add iproute2 bash \ No newline at end of file diff --git a/integration/docker-compose.yml b/integration/docker-compose.yml index c0381e3..848d792 100644 --- a/integration/docker-compose.yml +++ b/integration/docker-compose.yml @@ -11,11 +11,9 @@ services: - u_net volumes: - ../target/x86_64-unknown-linux-musl/release/u_server:/u_server - - ../:/unki/ + - ../certs:/unki/certs working_dir: /unki - command: bash -c " - export DATABASE_URL=postgres://$${DB_USER}:$${DB_PASSWORD}@$${DB_HOST}/$${DB_NAME} && - diesel setup && diesel migration run && /u_server" + command: /u_server depends_on: u_db: condition: service_healthy @@ -27,7 +25,7 @@ services: environment: RUST_LOG: trace healthcheck: - test: /bin/ss -tlpn | grep 63714 + test: ss -tlpn | grep 63714 interval: 5s timeout: 2s retries: 2 @@ -41,11 +39,17 @@ services: env_file: - ../.env - ../.env.private + working_dir: /unki + volumes: + - ../migrations:/unki/migrations + - ../Cargo.toml:/unki/Cargo.toml + command: /unki/u_db_entrypoint.sh healthcheck: - test: /bin/ss -tlpn | grep 5432 + # test if db's port is open and db is created + test: ss -tlpn | grep 5432 && psql -lqt -U $${DB_USER} | grep -qw $${DB_NAME} interval: 5s - timeout: 2s - retries: 2 + timeout: 5s + retries: 3 u_agent_1: image: unki/u_agent