diff --git a/.env b/.env index b8b4c8a..3603323 100644 --- a/.env +++ b/.env @@ -1,4 +1,3 @@ NEOGO_VERSION=0.105.1 AIO_VERSION=0.40.1 -HTTPGW_VERSION=0.28.0 -RESTGW_VERSION=0.7.1 +RESTGW_VERSION=0.8.2 diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 759d490..ca388b6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -71,6 +71,5 @@ jobs: NEOGO_HUB_TAG=${{ steps.setver.outputs.NEOGO_VERSION }} NEOFS_HUB_IMAGE=nspccdev/neofs NEOFS_HUB_TAG=${{ steps.setver.outputs.AIO_VERSION }} - NEOFS_HTTP_HUB_TAG=${{ steps.setver.outputs.HTTPGW_VERSION }} NEOFS_REST_HUB_TAG=${{ steps.setver.outputs.RESTGW_VERSION }} tags: nspccdev/neofs-aio:${{ steps.setver.outputs.AIO_VERSION }}${{ steps.setlatest.outputs.latest }} diff --git a/Dockerfile b/Dockerfile index d53085f..e3bd980 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,6 @@ ARG NEOFS_HUB_IMAGE=nspccdev/neofs ARG NEOFS_HUB_TAG=latest ARG NEOGO_HUB_IMAGE=nspccdev/neo-go ARG NEOGO_HUB_TAG=latest -ARG NEOFS_HTTP_HUB_TAG=latest ARG NEOFS_REST_HUB_TAG=latest FROM ${NEOGO_HUB_IMAGE}:${NEOGO_HUB_TAG} as neo-go @@ -10,7 +9,6 @@ FROM ${NEOFS_HUB_IMAGE}-cli:${NEOFS_HUB_TAG} as neofs-cli FROM ${NEOFS_HUB_IMAGE}-ir:${NEOFS_HUB_TAG} as neofs-ir FROM ${NEOFS_HUB_IMAGE}-storage:${NEOFS_HUB_TAG} as neofs-storage FROM ${NEOFS_HUB_IMAGE}-adm:${NEOFS_HUB_TAG} as neofs-adm -FROM ${NEOFS_HUB_IMAGE}-http-gw:${NEOFS_HTTP_HUB_TAG} as neofs-http-gw FROM ${NEOFS_HUB_IMAGE}-rest-gw:${NEOFS_REST_HUB_TAG} as neofs-rest-gw # Executable image @@ -31,13 +29,11 @@ COPY --from=neofs-cli /bin/neofs-cli /usr/bin/neofs-cli COPY --from=neofs-ir /bin/neofs-ir /usr/bin/neofs-ir COPY --from=neofs-storage /bin/neofs-node /usr/bin/neofs-node COPY --from=neofs-adm /bin/neofs-adm /usr/bin/neofs-adm -COPY --from=neofs-http-gw /bin/neofs-http-gw /usr/bin/neofs-http-gw COPY --from=neofs-rest-gw /bin/neofs-rest-gw /usr/bin/neofs-rest-gw COPY ./sn/cli-cfg.yaml /config/cli-cfg-sn.yaml COPY ./sn/wallet.json /config/wallet-sn.json COPY ./sn/config.yaml /config/config-sn.yaml -COPY ./http/wallet.json /config/wallet-http.json COPY ./rest-gw/wallet.json /config/wallet-rest.json COPY ./ir/cli-cfg.yaml /config/cli-cfg-ir.yaml COPY ./ir/config.yaml /config/config-ir.yaml @@ -45,8 +41,7 @@ COPY ./ir/node-wallet.json /config/node-wallet.json COPY ./ir/node-config.yaml /config/node-config.yaml COPY ./bin/ /config/bin -COPY ./http/http.env /config/http.env COPY ./rest-gw/rest.env /config/rest.env -RUN sed -ri 's,^([^=]+)=(.*)+$,\1=${\1-\2},' /config/http.env /config/rest.env +RUN sed -ri 's,^([^=]+)=(.*)+$,\1=${\1-\2},' /config/rest.env ENTRYPOINT ["/config/bin/init-aio.sh"] diff --git a/Makefile b/Makefile index 9657cfb..b95012a 100644 --- a/Makefile +++ b/Makefile @@ -21,7 +21,6 @@ image-aio: --build-arg NEOFS_HUB_TAG=$(AIO_VERSION) \ --build-arg NEOGO_HUB_IMAGE=$(NEOGO_HUB_IMAGE) \ --build-arg NEOGO_HUB_TAG=$(NEOGO_VERSION) \ - --build-arg NEOFS_HTTP_HUB_TAG=$(HTTPGW_VERSION) \ --build-arg NEOFS_REST_HUB_TAG=$(RESTGW_VERSION) \ -f Dockerfile \ -t $(AIO_IMAGE):$(AIO_VERSION) . @@ -35,6 +34,5 @@ version: @echo $(VERSION) @echo "neofs-node: $(AIO_VERSION)" @echo "neo-go: $(NEOGO_VERSION)" - @echo "neofs-http-gw: $(HTTPGW_VERSION)" @echo "neofs-rest-gw: $(RESTGW_VERSION)" diff --git a/README.md b/README.md index d7a930c..fd38e2e 100644 --- a/README.md +++ b/README.md @@ -88,12 +88,12 @@ First, you need to create a container to store your object. Because there is only one storage node in the All-in-One setup, you can only have one replica of your data. Let's create a container using `neofs-cli`. Container creation requires on-chain operations, so it may take up to 5-10 seconds to complete. -Here we use the pre-generated key of the HTTP Gateway for simplicity. +Here we use the pre-generated key of the REST Gateway for simplicity. Password for wallet is `one`. ``` sh -$ neofs-cli -r localhost:8080 -w http/wallet.json \ +$ neofs-cli -r localhost:8080 -w rest-gw/wallet.json \ --address NPFCqWHfi9ixCJRu7DABRbVfXRbkSEr9Vo \ container create \ --policy "REP 1" --basic-acl public-read --await @@ -126,7 +126,7 @@ $ curl http://localhost:8090/v1/containers/GfWw35kHds7gKWmSvW7Zi4U39K7NMLK8EfXBQ ## Put an object with neofs-cli ``` sh -$ neofs-cli -r localhost:8080 -w http/wallet.json \ +$ neofs-cli -r localhost:8080 -w rest-gw/wallet.json \ --address NPFCqWHfi9ixCJRu7DABRbVfXRbkSEr9Vo \ object put \ --cid GfWw35kHds7gKWmSvW7Zi4U39K7NMLK8EfXBQ5FPJA46 \ @@ -136,19 +136,21 @@ $ neofs-cli -r localhost:8080 -w http/wallet.json \ CID: GfWw35kHds7gKWmSvW7Zi4U39K7NMLK8EfXBQ5FPJA46 ``` -## Put an object via http +## Put an object via REST ``` sh $ curl -F 'file=@cat.jpg;filename=cat.jpg' \ - http://localhost:8081/upload/ADsJLhJhLQRGMufFin56PCTtPK1BiSxbg6bDmdgSB1Mo + http://localhost:8090/v1/upload/ADsJLhJhLQRGMufFin56PCTtPK1BiSxbg6bDmdgSB1Mo { "object_id": "B4J4L61X6zFcz5fcmZaCJJNZfFFTE6uT4pz7dqP87m6m", "container_id": "ADsJLhJhLQRGMufFin56PCTtPK1BiSxbg6bDmdgSB1Mo" } ``` -The full description of HTTP API supported by HTTP Gateway can be found in -[neofs-http-gw repository](https://github.com/nspcc-dev/neofs-http-gw). +The full description of REST API supported by NeoFS REST gateway can be found in +its OpenAPI specification ([http://localhost:8090](http://localhost:8090) shows +it), for more info take a look at [neofs-rest-gw repository](https://github.com/nspcc-dev/neofs-rest-gw) +as well. ## Get an object via nginx @@ -167,7 +169,7 @@ x-container-id: ADsJLhJhLQRGMufFin56PCTtPK1BiSxbg6bDmdgSB1Mo Content-Disposition: inline; filename=cat.jpg ``` -Having nginx as a reverse proxy behind NeoFS HTTP Gateway allows you to tune the +Having nginx as a reverse proxy for NeoFS REST Gateway allows you to tune the behaviour according to your application needs. For example, you can set the rewriting rules to use the pre-configured container for a specific domain to simplify the URL. Together with `FilePath` attribute in objects it would give @@ -179,19 +181,20 @@ For example: location / { set $cid ADsJLhJhLQRGMufFin56PCTtPK1BiSxbg6bDmdgSB1Mo; - rewrite '^(/[0-9a-zA-Z\-]{43,44})$' /get/$cid/$1 break; - rewrite '^/$' /get_by_attribute/$cid/FileName/index.html break; - rewrite '^/([^/]*)$' /get_by_attribute/$cid/FileName/$1 break; - rewrite '^(/.*)$' /get_by_attribute/$cid/FilePath/$1 break; + rewrite '^(/v1/.*)$' $1 break; + rewrite '^(/[0-9a-zA-Z\-]{43,44})$' /v1/get/$cid/$1 break; + rewrite '^/$' /v1/get_by_attribute/$cid/FileName/index.html break; + rewrite '^/([^/]*)$' /v1/get_by_attribute/$cid/FileName/$1 break; + rewrite '^(/.*)$' /v1/get_by_attribute/$cid/FilePath/$1 break; - proxy_pass http://localhost:8081; + proxy_pass http://localhost:8083; ``` This allow us to upload objects with `FilePath` attached and get them as if they were put in a directory structure of the regular web server. ``` sh - curl -F 'file=@cat.jpg;filename=cat.jpg' -H "X-Attribute-FilePath: /pic/cat.jpg" http://localhost:8081/upload/ADsJLhJhLQRGMufFin56PCTtPK1BiSxbg6bDmdgSB1Mo + curl -F 'file=@cat.jpg;filename=cat.jpg' -H "X-Attribute-FilePath: /pic/cat.jpg" http://localhost:8090/v1/upload/ADsJLhJhLQRGMufFin56PCTtPK1BiSxbg6bDmdgSB1Mo { "object_id": "4s3T11pktSfSxRfjpJ7BsiuYr2hi7po6nUQ333SPYkWF", "container_id": "ADsJLhJhLQRGMufFin56PCTtPK1BiSxbg6bDmdgSB1Mo" diff --git a/bin/init-aio.sh b/bin/init-aio.sh index 01927ae..f545746 100755 --- a/bin/init-aio.sh +++ b/bin/init-aio.sh @@ -3,8 +3,6 @@ ## When we start AIO as a separate container or part of a docker-compose. In this case we move background tasks to foreground. ## Otherwise we may use AIO container like a base for own container, thus we need just run all AIO services, before our service. IS_PURE_START="true" -## if "true" http service will be started -IS_START_HTTP="true" ## if "true" rest service will be started IS_START_REST="true" @@ -13,9 +11,6 @@ while getopts d:h:r: option; do d) IS_PURE_START="$OPTARG" ;; - h) - IS_START_HTTP="$OPTARG" - ;; r) IS_START_REST="$OPTARG" ;; @@ -41,9 +36,8 @@ ${NEOGO} wallet nep17 transfer \ --from ${CONSADDR} --force \ --to ${SNADDR} \ --token GAS \ - --amount 100 - -sleep 2 # https://github.com/nspcc-dev/neo-go/issues/3244 + --amount 100 \ + --await set -m /usr/bin/neofs-node --config /config/config-sn.yaml & @@ -60,16 +54,6 @@ set -a ./bin/config.sh ContainerFee 0 && ./bin/config.sh ContainerAliasFee 0 -if [ $IS_START_HTTP = "true" ]; then - . /config/http.env - /usr/bin/neofs-http-gw & - - while [[ "$(curl -s -o /dev/null -w %{http_code} $HTTP_GW_SERVER_0_ADDRESS)" != "404" ]]; - do - sleep 1; - done -fi - if [ $IS_START_REST = "true" ]; then . /config/rest.env /usr/bin/neofs-rest-gw & diff --git a/docker-compose.yml b/docker-compose.yml index 08d4e5e..935aa7b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -10,13 +10,11 @@ services: restart: always stop_signal: SIGKILL env_file: - - "./http/http.env" - "./rest-gw/rest.env" volumes: - ./sn/cli-cfg.yaml:/config/cli-cfg-sn.yaml - ./sn/wallet.json:/config/wallet-sn.json - ./sn/config.yaml:/config/config-sn.yaml - - ./http/wallet.json:/config/wallet-http.json - ./rest-gw/wallet.json:/config/wallet-rest.json - ./ir/cli-cfg.yaml:/config/cli-cfg-ir.yaml - ./ir/config.yaml:/config/config-ir.yaml @@ -25,7 +23,6 @@ services: - "30333:30333" # RPC - "8080:8080" # NeoFS API RPC - "16513:16513" # Control service - - "8081:8081" # HTTP Gateway endpoint - "8090:8090" # REST Gateway endpoint nginx_gw: @@ -36,7 +33,7 @@ services: restart: on-failure stop_signal: SIGKILL volumes: - - ./http/nginx.conf:/etc/nginx/nginx.conf + - ./rest-gw/nginx.conf:/etc/nginx/nginx.conf - cache:/cache ports: - "8082:8082" # nginx gateway endpoint diff --git a/http/http.env b/http/http.env deleted file mode 100644 index bf6f47d..0000000 --- a/http/http.env +++ /dev/null @@ -1,23 +0,0 @@ -HTTP_GW_SERVER_0_ADDRESS=0.0.0.0:8081 -HTTP_GW_RPC_ENDPOINT=http://localhost:30333 - -HTTP_GW_LOGGER_LEVEL=info - -HTTP_GW_REBALANCE_TIMER=5m -HTTP_GW_CONNECT_TIMEOUT=60s -HTTP_GW_REQUEST_TIMEOUT=300s - -HTTP_GW_KEEPALIVE_TIMEOUT=300s -HTTP_GW_KEEPALIVE_TIME=120s -HTTP_GW_KEEPALIVE_PERMIT_WITHOUT_STREAM=True - -HTTP_GW_METRICS=False -HTTP_GW_PPROF=False -HTTP_GW_VERBOSE=false - -HTTP_GW_WALLET=/config/wallet-http.json -HTTP_GW_WALLET_PASSPHRASE=one -HTTP_GW_ADDRESS=NPFCqWHfi9ixCJRu7DABRbVfXRbkSEr9Vo - -HTTP_GW_PEERS_0_ADDRESS=localhost:8080 -HTTP_GW_PEERS_0_WEIGHT=1 diff --git a/http/wallet.json b/http/wallet.json deleted file mode 100644 index fa96b42..0000000 --- a/http/wallet.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "version": "3.0", - "accounts": [ - { - "address": "NPFCqWHfi9ixCJRu7DABRbVfXRbkSEr9Vo", - "key": "6PYTAGjdaeicUDPqGv9mmgwb9kTwimWJJmmfNqJSDGH9qM79zSRcL9oHiB", - "label": "HTTP Gateway", - "contract": { - "script": "DCECcuPzZCZ2VyDsm2jKEOMnU6xEWO2bF1dvOvBWTDFYB1ZBVuezJw==", - "parameters": [ - { - "name": "parameter0", - "type": "Signature" - } - ], - "deployed": false - }, - "lock": false, - "isDefault": false - } - ], - "scrypt": { - "n": 16384, - "r": 8, - "p": 8 - }, - "extra": { - "Tokens": null - } -} diff --git a/http/nginx.conf b/rest-gw/nginx.conf similarity index 78% rename from http/nginx.conf rename to rest-gw/nginx.conf index 1715dc2..b139fcc 100644 --- a/http/nginx.conf +++ b/rest-gw/nginx.conf @@ -27,12 +27,12 @@ http { return 204; } - rewrite '^(/[0-9a-zA-Z]{43,44}/[0-9a-zA-Z\-]{43,44})$' /get/$1 break; - rewrite '^/([0-9a-zA-Z]{43,44})/$' /get_by_attribute/$1/FileName/index.html break; - rewrite '^/([0-9a-zA-Z]{43,44})/([^/]*)$' /get_by_attribute/$1/FileName/$2 break; - rewrite '^/([0-9a-zA-Z]{43,44})/(.*)$' /get_by_attribute/$1/FilePath/$2 break; + rewrite '^(/[0-9a-zA-Z]{43,44}/[0-9a-zA-Z\-]{43,44})$' /v1/get/$1 break; + rewrite '^/([0-9a-zA-Z]{43,44})/$' /v1/get_by_attribute/$1/FileName/index.html break; + rewrite '^/([0-9a-zA-Z]{43,44})/([^/]*)$' /v1/get_by_attribute/$1/FileName/$2 break; + rewrite '^/([0-9a-zA-Z]{43,44})/(.*)$' /v1/get_by_attribute/$1/FilePath/$2 break; - proxy_pass http://aio:8081; + proxy_pass http://aio:8090; proxy_http_version 1.1; proxy_intercept_errors on; proxy_buffering on;