Browse Source

Merge pull request #486 from provokateurin/fix/web-server

Fix/web server
pull/491/head
Kate 1 year ago committed by GitHub
parent
commit
fe7ad7899d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 16
      packages/nextcloud/test/helper.dart
  2. 10
      packages/nextcloud/test/news_test.dart
  3. 6
      tool/Dockerfile.dev
  4. 2
      tool/dev.sh
  5. 2
      tool/update.sh

16
packages/nextcloud/test/helper.dart

@ -144,7 +144,7 @@ Future<TestNextcloudClient> getTestClient(
return client; return client;
} }
Future<DockerContainer> getDockerContainer(final DockerImage image) async { Future<DockerContainer> getDockerContainer(final DockerImage image, {final bool useApache = false}) async {
late ProcessResult result; late ProcessResult result;
late int port; late int port;
while (true) { while (true) {
@ -155,12 +155,16 @@ Future<DockerContainer> getDockerContainer(final DockerImage image) async {
'run', 'run',
'--rm', '--rm',
'-d', '-d',
'--net', '--add-host',
'host', 'host.docker.internal:host-gateway',
'-p',
'$port:80',
image, image,
'php', if (!useApache) ...[
'-S', 'php',
'0.0.0.0:$port', '-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

10
packages/nextcloud/test/news_test.dart

@ -25,12 +25,12 @@ Future run(final DockerImage image) async {
tearDown(() => container.destroy()); tearDown(() => container.destroy());
Future<NewsListFeeds> addWikipediaFeed([final int? folderID]) => client.news.addFeed( Future<NewsListFeeds> addWikipediaFeed([final int? folderID]) => client.news.addFeed(
url: 'http://localhost:${rssServer.port}/wikipedia.xml', url: 'http://host.docker.internal:${rssServer.port}/wikipedia.xml',
folderId: folderID, folderId: folderID,
); );
Future<NewsListFeeds> addNasaFeed() => client.news.addFeed( Future<NewsListFeeds> addNasaFeed() => client.news.addFeed(
url: 'http://localhost:${rssServer.port}/nasa.xml', url: 'http://host.docker.internal:${rssServer.port}/nasa.xml',
); );
test('Is supported', () async { test('Is supported', () async {
@ -48,13 +48,13 @@ Future run(final DockerImage image) async {
expect(response.starredCount, null); expect(response.starredCount, null);
expect(response.newestItemId, isNotNull); expect(response.newestItemId, isNotNull);
expect(response.feeds, hasLength(1)); expect(response.feeds, hasLength(1));
expect(response.feeds[0].url, 'http://localhost:${rssServer.port}/wikipedia.xml'); expect(response.feeds[0].url, 'http://host.docker.internal:${rssServer.port}/wikipedia.xml');
response = await client.news.listFeeds(); response = await client.news.listFeeds();
expect(response.starredCount, 0); expect(response.starredCount, 0);
expect(response.newestItemId, isNotNull); expect(response.newestItemId, isNotNull);
expect(response.feeds, hasLength(1)); expect(response.feeds, hasLength(1));
expect(response.feeds[0].url, 'http://localhost:${rssServer.port}/wikipedia.xml'); expect(response.feeds[0].url, 'http://host.docker.internal:${rssServer.port}/wikipedia.xml');
}); });
test('Rename feed', () async { test('Rename feed', () async {
@ -247,7 +247,7 @@ Future run(final DockerImage image) async {
expect(response.newestItemId, isNotNull); expect(response.newestItemId, isNotNull);
expect(response.feeds, hasLength(1)); expect(response.feeds, hasLength(1));
expect(response.feeds[0].folderId, 1); expect(response.feeds[0].folderId, 1);
expect(response.feeds[0].url, 'http://localhost:${rssServer.port}/wikipedia.xml'); expect(response.feeds[0].url, 'http://host.docker.internal:${rssServer.port}/wikipedia.xml');
}); });
test('Mark folder as read', () async { test('Mark folder as read', () async {

6
tool/Dockerfile.dev

@ -1,5 +1,7 @@
FROM nextcloud:27.0.0-fpm-alpine FROM nextcloud:27.0.0
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
@ -18,5 +20,3 @@ 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 && \ until curl -s -o /dev/null http://localhost:8080/status.php; do true; done && \
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:8080/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/
CMD ["php", "-S", "0.0.0.0:80"]

2
tool/dev.sh

@ -5,4 +5,4 @@ cd "$(dirname "$0")/.."
./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" --net="host" nextcloud-neon-dev 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 nextcloud-neon-dev

2
tool/update.sh

@ -27,7 +27,7 @@ elif [ -d "external/nextcloud-$1" ]; then
# shellcheck disable=SC2001 # shellcheck disable=SC2001
latest_version=$(echo "$latest_tag" | sed "s/^v//") latest_version=$(echo "$latest_tag" | sed "s/^v//")
if [[ "$1" == "server" ]]; then if [[ "$1" == "server" ]]; then
sed -i "s/FROM nextcloud:.*/FROM nextcloud:$latest_version-fpm-alpine/" ../../tool/Dockerfile.dev sed -i "s/FROM nextcloud:.*/FROM nextcloud:$latest_version/" ../../tool/Dockerfile.dev
else else
sed -i "s/RUN \.\/occ app:install $1 .*/RUN .\/occ app:install $1 --force --allow-unstable # $latest_version/" ../../tool/Dockerfile.dev sed -i "s/RUN \.\/occ app:install $1 .*/RUN .\/occ app:install $1 --force --allow-unstable # $latest_version/" ../../tool/Dockerfile.dev
fi fi

Loading…
Cancel
Save