From: Felix Ableitner Date: Mon, 31 Aug 2020 15:26:32 +0000 (+0200) Subject: Simplify docker federation setup X-Git-Url: http://these/git/%7B%60%24%7BwebArchiveUrl%7D/%22%7B%7D/readmes/%7B%7D/%22%7Burl%7D/%7Bthis.imageSrc%7D?a=commitdiff_plain;h=147972273a72e713f480a3ee994fbfdc4cb0e037;p=lemmy.git Simplify docker federation setup --- diff --git a/docker/federation-test/servers.sh b/docker/federation-test/servers.sh deleted file mode 100755 index 5b09bc95..00000000 --- a/docker/federation-test/servers.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/bash -set -e - -sudo docker-compose --file ../federation/docker-compose.yml --project-directory . down -sudo rm -rf volumes - -pushd ../../server/ -cargo build -popd - -pushd ../../ui -yarn -popd - -mkdir -p volumes/pictrs_{alpha,beta,gamma,delta,epsilon} -sudo chown -R 991:991 volumes/pictrs_{alpha,beta,gamma,delta,epsilon} - -sudo docker build ../../ --file ../federation/Dockerfile --tag lemmy-federation:latest - -sudo docker-compose --file ../federation/docker-compose.yml --project-directory . up diff --git a/docker/federation-test/tests.sh b/docker/federation-test/tests.sh deleted file mode 100755 index 58472e95..00000000 --- a/docker/federation-test/tests.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash -set -xe - -pushd ../../ui -echo "Waiting for Lemmy to start..." -while [[ "$(curl -s -o /dev/null -w '%{http_code}' 'localhost:8540/api/v1/site')" != "200" ]]; do sleep 1; done -while [[ "$(curl -s -o /dev/null -w '%{http_code}' 'localhost:8550/api/v1/site')" != "200" ]]; do sleep 1; done -while [[ "$(curl -s -o /dev/null -w '%{http_code}' 'localhost:8560/api/v1/site')" != "200" ]]; do sleep 1; done -while [[ "$(curl -s -o /dev/null -w '%{http_code}' 'localhost:8570/api/v1/site')" != "200" ]]; do sleep 1; done -while [[ "$(curl -s -o /dev/null -w '%{http_code}' 'localhost:8580/api/v1/site')" != "200" ]]; do sleep 1; done -yarn api-test || true -popd diff --git a/docker/federation/Dockerfile b/docker/federation/Dockerfile deleted file mode 100644 index caf08175..00000000 --- a/docker/federation/Dockerfile +++ /dev/null @@ -1,17 +0,0 @@ -FROM ekidd/rust-musl-builder:1.42.0-openssl11 - -USER root -RUN mkdir /app/dist/documentation/ -p \ - && addgroup --gid 1001 lemmy \ - && adduser --gecos "" --disabled-password --shell /bin/sh -u 1001 --ingroup lemmy lemmy - -# Copy resources -COPY server/config/defaults.hjson /app/config/defaults.hjson -COPY ui/dist /app/dist -COPY server/target/debug/lemmy_server /app/lemmy - -RUN chown lemmy:lemmy /app/ -R -USER lemmy -EXPOSE 8536 -WORKDIR /app -CMD ["/app/lemmy"] diff --git a/docker/federation/docker-compose.yml b/docker/federation/docker-compose.yml index 32fee74a..49c4ae85 100644 --- a/docker/federation/docker-compose.yml +++ b/docker/federation/docker-compose.yml @@ -10,8 +10,7 @@ services: - "8570:8570" - "8580:8580" volumes: - # Hack to make this work from both docker/federation/ and docker/federation-test/ - - ../federation/nginx.conf:/etc/nginx/nginx.conf + - ./nginx.conf:/etc/nginx/nginx.conf restart: on-failure depends_on: - pictrs diff --git a/docker/federation/run-federation-test.bash b/docker/federation/run-federation-test.bash deleted file mode 100755 index 0fe03aa1..00000000 --- a/docker/federation/run-federation-test.bash +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/bash -set -e - -# already start rust build in the background -pushd ../../server/ || exit -cargo build & -popd || exit - -if [ "$1" != "--no-yarn-build" ]; then - pushd ../../ui/ || exit - yarn - yarn build - popd || exit -fi - -# wait for rust build to finish -pushd ../../server/ || exit -cargo build -popd || exit - -sudo docker build ../../ --file Dockerfile -t lemmy-federation:latest - -for Item in alpha beta gamma delta epsilon ; do - sudo mkdir -p volumes/pictrs_$Item - sudo chown -R 991:991 volumes/pictrs_$Item -done - -sudo docker-compose up diff --git a/docker/federation-test/run-tests.sh b/docker/federation/run-tests.sh similarity index 68% rename from docker/federation-test/run-tests.sh rename to docker/federation/run-tests.sh index f166d490..bb4a29d6 100755 --- a/docker/federation-test/run-tests.sh +++ b/docker/federation/run-tests.sh @@ -2,26 +2,18 @@ set -e # make sure there are no old containers or old data around -sudo docker-compose --file ../federation/docker-compose.yml --project-directory . down +sudo docker-compose down sudo rm -rf volumes -pushd ../../server/ -cargo build -popd - -pushd ../../ui -yarn -popd - mkdir -p volumes/pictrs_{alpha,beta,gamma,delta,epsilon} sudo chown -R 991:991 volumes/pictrs_{alpha,beta,gamma,delta,epsilon} -sudo docker build ../../ --file ../federation/Dockerfile --tag lemmy-federation:latest +sudo docker build ../../ --file ../dev/Dockerfile --tag lemmy-federation:latest sudo mkdir -p volumes/pictrs_alpha sudo chown -R 991:991 volumes/pictrs_alpha -sudo docker-compose --file ../federation/docker-compose.yml --project-directory . up -d +sudo docker-compose up -d pushd ../../ui echo "Waiting for Lemmy to start..." @@ -33,6 +25,6 @@ while [[ "$(curl -s -o /dev/null -w '%{http_code}' 'localhost:8580/api/v1/site') yarn api-test || true popd -sudo docker-compose --file ../federation/docker-compose.yml --project-directory . down +sudo docker-compose down -sudo rm -r volumes/ +sudo rm -r volumes diff --git a/docker/federation/start-local-instances.bash b/docker/federation/start-local-instances.bash new file mode 100755 index 00000000..6814fdd7 --- /dev/null +++ b/docker/federation/start-local-instances.bash @@ -0,0 +1,11 @@ +#!/bin/bash +set -e + +sudo docker build ../../ --file ../dev/Dockerfile -t lemmy-federation:latest + +for Item in alpha beta gamma delta epsilon ; do + sudo mkdir -p volumes/pictrs_$Item + sudo chown -R 991:991 volumes/pictrs_$Item +done + +sudo docker-compose up diff --git a/docs/src/contributing_federation_development.md b/docs/src/contributing_federation_development.md index 8af38a07..08c4e5ca 100644 --- a/docs/src/contributing_federation_development.md +++ b/docs/src/contributing_federation_development.md @@ -14,25 +14,30 @@ You need to have the following packages installed, the Docker service needs to b - docker - docker-compose -- cargo -- yarn Then run the following ```bash cd docker/federation -./run-federation-test.bash -yarn +./start-local-instances.bash ``` -The federation test sets up 3 instances: +The federation test sets up 5 instances: -Instance / Username | Location ---- | --- -lemmy_alpha | [127.0.0.1:8540](http://127.0.0.1:8540) -lemmy_beta | [127.0.0.1:8550](http://127.0.0.1:8550) -lemmy_gamma | [127.0.0.1:8560](http://127.0.0.1:8560) +Instance | Username | Location | Notes +--- | --- | --- | --- +lemmy-alpha | lemmy_alpha | [127.0.0.1:8540](http://127.0.0.1:8540) | federated with all other instances +lemmy-beta | lemmy_beta | [127.0.0.1:8550](http://127.0.0.1:8550) | federated with all other instances +lemmy-gamma | lemmy_gamma | [127.0.0.1:8560](http://127.0.0.1:8560) | federated with all other instances +lemmy-delta | lemmy_delta | [127.0.0.1:8570](http://127.0.0.1:8570) | only allows federation with lemmy-beta +lemmy-epsilon | lemmy_epsilon | [127.0.0.1:8580](http://127.0.0.1:8580) | uses blocklist, has lemmy-alpha blocked You can log into each using the instance name, and `lemmy` as the password, IE (`lemmy_alpha`, `lemmy`). +To start federation between instances, visit one of them and search for a user, community or post, like this: +- `!main@lemmy-alpha:8540` +- `http://lemmy-beta:8550/post/3` +- `@lemmy-gamma@lemmy-gamma:8560` + Firefox containers are a good way to test them interacting. ## Integration tests @@ -40,8 +45,8 @@ Firefox containers are a good way to test them interacting. To run a suite of suite of federation integration tests: ```bash -cd docker/federation-test -./run-tests.sh +cd docker/federation +./run-tests.bash ``` ## Running on a server