diff --git a/Dockerfile b/Dockerfile index b1a813c..f7fe4b3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,5 +13,5 @@ COPY --chmod=0755 output/simple_object_storage.${TARGETARCH} /sos/sos # Expose port EXPOSE 80 -# Run server (assuming config is mounted at /data/config.json) +# Run server (assuming config is mounted at /data/sos_config.json) CMD ["/sos/sos"] \ No newline at end of file diff --git a/README.md b/README.md index 10f9c02..6adefbe 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,7 @@ docker build -t simple-object-storage . docker run -d \ -p 8080:8080 \ -v /path/to/storage:/data/storage \ - -v /path/to/config.json:/data/sos_config.json:ro \ + -v /path/to/sos_config.json:/data/sos_config.json:ro \ --name object-storage \ simple-object-storage ``` @@ -50,7 +50,7 @@ This will: - Mount your config directory to the container - Run the service in detached mode -Ensure that the `storage_path` set in the `config.json` is `/data/storage`, the path inside the container. +Ensure that the `storage_path` set in the `sos_config.json` is `/data/storage`, the path inside the container. ### Using Docker Compose @@ -65,7 +65,7 @@ services: - "8080:8080" volumes: - /path/to/storage:/data/storage - - /path/to/config.json:/data/sos_config.json:ro + - /path/to/sos_config.json:/data/sos_config.json:ro restart: unless-stopped ``` @@ -76,7 +76,7 @@ docker-compose up -d ## Configuration -The server can be configured by creating a JSON configuration file at `~/.config/simple_object_storage/config.json`. Default values are shown below (everything but write tokens), suitable for running in Docker. +The server can be configured by creating a JSON configuration file at `~/.config/simple_object_storage/sos_config.json`. Default values are shown below (everything but write tokens), suitable for running in Docker. ```json { diff --git a/src/main.cpp b/src/main.cpp index d82fa0c..467476f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -25,8 +25,8 @@ std::filesystem::path get_config_path() { // check for config in the following paths: std::vector config_paths = { "/data/sos_config.json", - _home / ".config/simple_object_storage/config.json", - _exe / ".." / ".test" / "config.json", + _home / ".config/simple_object_storage/sos_config.json", + "sos_config.json", "/testing/sos_config.json" }; diff --git a/testing/config.json b/testing/sos_config.json similarity index 100% rename from testing/config.json rename to testing/sos_config.json diff --git a/testing/test-docker.sh b/testing/test-docker.sh index 16df956..1584b40 100755 --- a/testing/test-docker.sh +++ b/testing/test-docker.sh @@ -57,7 +57,7 @@ docker buildx build --no-cache --load -t gitea.jde.nz/public/simple-object-stora #------------------------------------------------------------------------------------------------ # run the docker container title "Running docker container" -export LOCALCONFIG="${SCRIPT_DIR}/config.json" +export LOCALCONFIG="${SCRIPT_DIR}/sos_config.json" export COMPOSE_FILE="${SCRIPT_DIR}/compose.yaml" [ -f "${LOCALCONFIG}" ] || die "Config file not found: ${LOCALCONFIG}" @@ -66,8 +66,11 @@ export COMPOSE_FILE="${SCRIPT_DIR}/compose.yaml" #------------------------------------------------------------------------------------------------ title "Running tests" +PREV_DIR=$(pwd) +cd "${SCRIPT_DIR}" + docker stop sos-test || true -docker rm sos-test || true +docker rm -v sos-test || true LOCALCONFIG=${LOCALCONFIG} docker compose -f "${COMPOSE_FILE}" up -d @@ -77,7 +80,6 @@ if ! wait_for_container "sos-test"; then echo "Container sos-test is not healthy" echo "----------------------------------------" docker logs sos-test - docker inspect sos-test die "Container sos-test is not healthy" fi @@ -89,5 +91,7 @@ RESULT=$? docker compose -f "${COMPOSE_FILE}" down docker compose -f "${COMPOSE_FILE}" rm -v +cd "${PREV_DIR}" + exit $RESULT diff --git a/testing/test.sh b/testing/test.sh index c40b150..f1c1fff 100755 --- a/testing/test.sh +++ b/testing/test.sh @@ -53,8 +53,8 @@ if ! command -v jq &> /dev/null; then exit 1 fi -# read ~/.config/simple_object_storage/config.json -CONFIG_PATH="${SCRIPT_DIR}/config.json" +# read sos_config.json +CONFIG_PATH="${SCRIPT_DIR}/sos_config.json" if [ ! -f "${CONFIG_PATH}" ]; then echo "config file not found at ${CONFIG_PATH}" exit 1 diff --git a/testing/test_1GB_file_upload.sh b/testing/test_1GB_file_upload.sh index 4899272..00bf1a6 100755 --- a/testing/test_1GB_file_upload.sh +++ b/testing/test_1GB_file_upload.sh @@ -1,8 +1,8 @@ #!/bin/bash -# read ~/.config/simple_object_storage/config.json -CONFIG_PATH="./config.json" +# read ~/.config/simple_object_storage/sos_config.json +CONFIG_PATH="./sos_config.json" if [ ! -f "${CONFIG_PATH}" ]; then echo "config file not found at ${CONFIG_PATH}" exit 1