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. 1
      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

1
CONTRIBUTING.md

@ -38,7 +38,6 @@ You can read the full documentation at https://www.conventionalcommits.org.
## Tools
We maintain a collection of scripts in `./tool/`.
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
For easier development we use a monorepo structure.

7
packages/nextcloud/test/helper.dart

@ -156,7 +156,7 @@ Future<TestNextcloudClient> getTestClient(
return client;
}
Future<DockerContainer> getDockerContainer(final DockerImage image, {final bool useApache = false}) async {
Future<DockerContainer> getDockerContainer(final DockerImage image) async {
late ProcessResult result;
late int port;
while (true) {
@ -172,11 +172,6 @@ Future<DockerContainer> getDockerContainer(final DockerImage image, {final bool
'-p',
'$port:80',
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

5
packages/nextcloud/test/spreed_test.dart

@ -18,10 +18,7 @@ void main() {
late DockerContainer container;
late TestNextcloudClient client1;
setUp(() async {
container = await getDockerContainer(
image,
useApache: true,
);
container = await getDockerContainer(image);
client1 = await getTestClient(container);
});
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
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 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 app:enable password_policy
RUN (sh /entrypoint.sh php -S 0.0.0.0:8080 &) && \
until curl -s -o /dev/null http://localhost:8080/status.php; do true; done && \
RUN (sh /entrypoint.sh php -S 0.0.0.0:80 &) && \
until curl -s -o /dev/null http://localhost/status.php; do true; done && \
# 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/
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
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
set -euxo pipefail
#!/bin/sh
set -euxo
app="$1"
url="$2"

Loading…
Cancel
Save