Browse Source

refactor(tool,nextcloud): Use php standalone webserver

Signed-off-by: jld3103 <jld3103yt@gmail.com>
pull/1067/head
jld3103 1 year ago
parent
commit
a4efe80419
No known key found for this signature in database
GPG Key ID: 9062417B9E8EB7B3
  1. 3
      CONTRIBUTING.md
  2. 7
      packages/nextcloud/test/helper.dart
  3. 5
      packages/nextcloud/test/spreed_test.dart
  4. 13
      tool/Dockerfile.dev
  5. 11
      tool/dev.sh
  6. 4
      tool/dev/install_app_version

3
CONTRIBUTING.md

@ -38,8 +38,7 @@ You can read the full documentation at https://www.conventionalcommits.org.
## Tools ## Tools
We maintain a collection of scripts in `./tool/`. We maintain a collection of scripts in `./tool/`.
They range from setting up a local Nextcloud server (`./tool/dev.sh`) to generating assets. They range from setting up a local Nextcloud server (`./tool/dev.sh`) to generating assets.
Be aware that due to limitations in Apache the dev server will crash when you resize the terminal window.
## Monorepo ## Monorepo
For easier development we use a monorepo structure. For easier development we use a monorepo structure.
This means that we have multiple packages in one git repository. This means that we have multiple packages in one git repository.

7
packages/nextcloud/test/helper.dart

@ -156,7 +156,7 @@ Future<TestNextcloudClient> getTestClient(
return client; return client;
} }
Future<DockerContainer> getDockerContainer(final DockerImage image, {final bool useApache = false}) async { Future<DockerContainer> getDockerContainer(final DockerImage image) async {
late ProcessResult result; late ProcessResult result;
late int port; late int port;
while (true) { while (true) {
@ -172,11 +172,6 @@ Future<DockerContainer> getDockerContainer(final DockerImage image, {final bool
'-p', '-p',
'$port:80', '$port:80',
image, image,
if (!useApache) ...[
'php',
'-S',
'0.0.0.0:80',
],
], ],
); );
// 125 means the docker run command itself has failed which indicated the port is already used // 125 means the docker run command itself has failed which indicated the port is already used

5
packages/nextcloud/test/spreed_test.dart

@ -18,10 +18,7 @@ void main() {
late DockerContainer container; late DockerContainer container;
late TestNextcloudClient client1; late TestNextcloudClient client1;
setUp(() async { setUp(() async {
container = await getDockerContainer( container = await getDockerContainer(image);
image,
useApache: true,
);
client1 = await getTestClient(container); client1 = await getTestClient(container);
}); });
tearDown(() => container.destroy()); tearDown(() => container.destroy());

13
tool/Dockerfile.dev

@ -1,9 +1,7 @@
ARG SERVER_VERSION=27.1.3@sha256:4ab3159b25310ffdb699f532d45f706d5d949100ed7ac11820d83467f29678b9 ARG SERVER_VERSION=27.1.3-fpm-alpine@sha256:70ddd4abb804bc061a4f882a81cc62a219b262c0ed1784439e66b091ef26104b
FROM nextcloud:$SERVER_VERSION FROM nextcloud:$SERVER_VERSION
WORKDIR /usr/src/nextcloud WORKDIR /usr/src/nextcloud
RUN chown -R www-data:www-data .
USER www-data
RUN ./occ maintenance:install --admin-pass admin --admin-email admin@example.com RUN ./occ maintenance:install --admin-pass admin --admin-email admin@example.com
RUN ./occ config:system:set allow_local_remote_servers --value=true RUN ./occ config:system:set allow_local_remote_servers --value=true
@ -30,8 +28,11 @@ RUN install_app_version spreed https://github.com/nextcloud-releases/spreed/rele
RUN ./occ talk:turn:add turn,turns staticauth.openrelay.metered.ca:443 udp,tcp --secret openrelayprojectsecret RUN ./occ talk:turn:add turn,turns staticauth.openrelay.metered.ca:443 udp,tcp --secret openrelayprojectsecret
RUN ./occ app:enable password_policy RUN ./occ app:enable password_policy
RUN (sh /entrypoint.sh php -S 0.0.0.0:8080 &) && \ RUN (sh /entrypoint.sh php -S 0.0.0.0:80 &) && \
until curl -s -o /dev/null http://localhost:8080/status.php; do true; done && \ until curl -s -o /dev/null http://localhost/status.php; do true; done && \
# Do not setup the demo user here # Do not setup the demo user here
for user in admin user1 user2; do curl -u "$user:$user" -H "ocs-apirequest: true" -s -o /dev/null http://localhost:8080/ocs/v2.php/cloud/user; done for user in admin user1 user2; do curl -u "$user:$user" -H "ocs-apirequest: true" -s -o /dev/null http://localhost/ocs/v2.php/cloud/user; done
COPY --chown=www-data:www-data overlay /usr/src/nextcloud/ COPY --chown=www-data:www-data overlay /usr/src/nextcloud/
ENV PHP_CLI_SERVER_WORKERS=10
CMD ["php", "-S", "0.0.0.0:80"]

11
tool/dev.sh

@ -6,4 +6,13 @@ source tool/common.sh
./tool/build-dev-container.sh ./tool/build-dev-container.sh
echo "Running development instance on http://localhost. To access it in an Android Emulator use http://10.0.2.2" echo "Running development instance on http://localhost. To access it in an Android Emulator use http://10.0.2.2"
docker run --rm -v nextcloud-neon-dev:/usr/src/nextcloud -v nextcloud-neon-dev:/var/www/html -p "80:80" --add-host=host.docker.internal:host-gateway "$(image_tag "dev:latest")"
container="$(docker run -d --rm -v nextcloud-neon-dev:/usr/src/nextcloud -v nextcloud-neon-dev:/var/www/html -p "80:80" --add-host=host.docker.internal:host-gateway "$(image_tag "dev:latest")")"
function cleanup() {
docker kill "$container"
}
trap cleanup EXIT
docker logs -f "$container" &
sleep infinity

4
tool/dev/install_app_version

@ -1,5 +1,5 @@
#!/bin/bash #!/bin/sh
set -euxo pipefail set -euxo
app="$1" app="$1"
url="$2" url="$2"

Loading…
Cancel
Save