From 18b78a981febbcff26440c4d067fdad63476e4f3 Mon Sep 17 00:00:00 2001 From: flowgunso Date: Sun, 2 Jun 2024 14:54:48 +0200 Subject: [PATCH] Specify target, move envvars to file, improve mocking --- Makefile | 17 ++++++++++------- seafile-client/Dockerfile | 5 ++++- tests/mock/compose.yaml | 36 ++++++++++++------------------------ tests/mock/create-library.sh | 6 ++++++ tests/mock/env | 19 +++++++++++++++++++ 5 files changed, 51 insertions(+), 32 deletions(-) create mode 100644 tests/mock/create-library.sh create mode 100644 tests/mock/env diff --git a/Makefile b/Makefile index 9dfe038..ed88d2a 100644 --- a/Makefile +++ b/Makefile @@ -1,20 +1,23 @@ -TARGET?=unstable +TARGET?=oldstable # or stable, unstable mock: - docker compose -f tests/mock/compose.yaml up -d + TARGET=${TARGET} docker compose -f tests/mock/compose.yaml up --remove-orphans -d unmock: - docker compose -f tests/mock/compose.yaml down + TARGET=${TARGET} docker compose -f tests/mock/compose.yaml down client: - docker compose -f tests/mock/compose.yaml rm -fs client - docker compose -f tests/mock/compose.yaml up -d client + TARGET=${TARGET} docker compose -f tests/mock/compose.yaml rm -fs client + TARGET=${TARGET} docker compose -f tests/mock/compose.yaml up --remove-orphans -d client shell: - docker compose -f tests/mock/compose.yaml exec client bash + TARGET=${TARGET} docker compose -f tests/mock/compose.yaml run --rm client bash logs: - docker compose -f tests/mock/compose.yaml logs -f client + TARGET=${TARGET} docker compose -f tests/mock/compose.yaml logs -f client + +ps: + TARGET=${TARGET} docker compose -f tests/mock/compose.yaml ps build: TARGET=${TARGET} CI_COMMIT_TAG=${CI_COMMIT_TAG} bash scripts/build-images.sh diff --git a/seafile-client/Dockerfile b/seafile-client/Dockerfile index f40bacc..0b0e559 100644 --- a/seafile-client/Dockerfile +++ b/seafile-client/Dockerfile @@ -15,7 +15,10 @@ RUN apt-get update && \ oathtool \ ca-certificates \ gnupg \ - sudo && \ + sudo \ + # procps \ + iputils-ping \ + && \ apt-get clean && apt-get autoclean && \ rm -rf \ /var/log/fsck/*.log \ diff --git a/tests/mock/compose.yaml b/tests/mock/compose.yaml index 4d9c020..d68d7d9 100644 --- a/tests/mock/compose.yaml +++ b/tests/mock/compose.yaml @@ -1,47 +1,35 @@ +name: seafile-client-${TARGET} + services: mariadb: image: mariadb:10.11 - environment: - - MYSQL_ROOT_PASSWORD=password # Requested, set the root's password of MySQL service. - - MYSQL_LOG_CONSOLE=true - - MARIADB_AUTO_UPGRADE=1 + env_file: env volumes: - database:/var/lib/mysql # Requested, specifies the path to MySQL data persistent store. memcached: image: memcached:1.6.18 - container_name: seafile-memcached entrypoint: memcached -m 256 seafile: image: seafileltd/seafile-mc:latest + hostname: seafile-${TARGET} ports: - - "80:80" + - "80" volumes: - seafile:/shared # Requested, specifies the path to Seafile data persistent store. - environment: - - DB_HOST=mariadb - - DB_ROOT_PASSWD=password # Requested, the value should be root's password of MySQL service. - - TIME_ZONE=Etc/UTC # Optional, default is UTC. Should be uncomment and set to your local time zone. - - SEAFILE_ADMIN_EMAIL=seafile@localhost # Specifies Seafile admin user, default is 'me@example.com'. - - SEAFILE_ADMIN_PASSWORD=password # Specifies Seafile admin password, default is 'asecret'. - - SEAFILE_SERVER_LETSENCRYPT=false # Whether to use https or not. + env_file: env depends_on: - mariadb - memcached client: - image: seafile-client:unstable - volumes: - #- library:/library - - data:/seafile -# user: "1000:1000" - environment: - SEAF_SERVER_URL: "http://seafile" - SEAF_USERNAME: "seafile@localhost" - SEAF_PASSWORD: "password" - SEAF_LIBRARY_UUID: "1b7d4e92-6753-4c4a-85b0-42566eab42c8" - DEBUG: 1 + # image: flowgunso/seafile-client:9.0.5 + image: seafile-client:${TARGET} + # volumes: + # - library:/library + # - data:/seafile + env_file: env UID: 1000 GID: 100 depends_on: diff --git a/tests/mock/create-library.sh b/tests/mock/create-library.sh new file mode 100644 index 0000000..247922f --- /dev/null +++ b/tests/mock/create-library.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +until curl --output /dev/null --silent --head --fail http://seafile-${TARGET}; do + printf '.' + sleep 5 +done \ No newline at end of file diff --git a/tests/mock/env b/tests/mock/env new file mode 100644 index 0000000..6e48823 --- /dev/null +++ b/tests/mock/env @@ -0,0 +1,19 @@ +# Database +MYSQL_ROOT_PASSWORD=password # Requested, set the root's password of MySQL service. +MYSQL_LOG_CONSOLE=true +MARIADB_AUTO_UPGRADE=1 + +# Seafile +DB_HOST=mariadb +DB_ROOT_PASSWD=password # Requested, the value should be root's password of MySQL service. +TIME_ZONE=Etc/UTC # Optional, default is UTC. Should be uncomment and set to your local time zone. +SEAFILE_ADMIN_EMAIL=seafile@localhost # Specifies Seafile admin user, default is 'me@example.com'. +SEAFILE_ADMIN_PASSWORD=password # Specifies Seafile admin password, default is 'asecret'. +SEAFILE_SERVER_LETSENCRYPT=false # Whether to use https or not. + +# Client +SEAF_SERVER_URL="http://seafile-${TARGET}" +SEAF_USERNAME="seafile@localhost" +SEAF_PASSWORD="password" +DEBUG=1 +# SEAF_LIBRARY_UUID="" # Use this for custom library ID