diff --git a/.env b/.env index c512695..43f2ae2 100644 --- a/.env +++ b/.env @@ -1,2 +1,2 @@ COMPOSE_PROJECT_NAME=localterra -TERRA_VERSION=2.4.0 +TERRA_VERSION=2.3.2 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f7849c1..bfa5c0e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -5,6 +5,7 @@ on: tags: - 'v[0-9]+.[0-9]+.[0-9]+' # Push events to matching v*, i.e. v1.0, v20.15.10 - 'v[0-9]+.[0-9]+.[0-9]+-rc*' # Push events to matching v*, i.e. v1.0-rc1, v20.15.10-rc5 + - 'v[0-9]+.[0-9]+.[0-9]+-classic' # Push events to matching v*, i.e. v1.0-classic, v20.15.10-classic jobs: artifacts: diff --git a/Dockerfile b/Dockerfile index 5b7df00..c8efee5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,20 +1,56 @@ -ARG TERRA_VERSION=2.3.1 +ARG TERRA_VERSION=2.3.2 FROM ghcr.io/terra-money/core:${TERRA_VERSION} +# Set up fo nginx +USER root + +COPY --chmod=644 nginx.conf /etc/nginx/nginx.conf +COPY --chmod=755 entrypoint.sh /usr/local/bin/entrypoint.sh + +RUN apk add --no-cache nginx && \ + mkdir -p /var/lib/nginx/logs && \ + chown -R terra:terra /var/lib/nginx && \ + ln -sf /dev/stdout /var/lib/nginx/logs/access.log && \ + ln -sf /dev/stderr /var/lib/nginx/logs/error.log + +# Setup for localterra +RUN set -eux &&\ + mkdir -p /app/conifg && \ + mkdir -p /app/data && \ + chown -R terra:terra /app && \ + terrad init localterra --home /app --chain-id localterra && \ + echo '{"height": "0","round": 0,"step": 0}' > /app/data/priv_validator_state.json && \ + sed -e '/^\[api\]/,/\[rosetta\]/ s|^enable *=.*|enable = true|' \ + -e '/^\[api\]/,/\[rosetta\]/ s|^swagger *=.*|swagger = true|' \ + -e '/^\[api\]/,/\[rosetta\]/ s|^enabled-unsafe-cors *=.*|enabled-unsafe-cors = true|' \ + -i /app/config/app.toml + COPY ./terra/genesis.json \ ./terra/priv_validator_key.json \ /app/config/ -RUN mkdir -p /app/data && \ - echo '{"height": "0","round": 0,"step": 0}' > /app/data/priv_validator_state.json +ENTRYPOINT [ "entrypoint.sh" ] + +# rest server +EXPOSE 1317 +# nginx +EXPOSE 8080 +# grpc +EXPOSE 9090 +# grpc-web +EXPOSE 9091 +# tendermint p2p +EXPOSE 26656 +# tendermint rpc +EXPOSE 26657 CMD terrad start \ - --api.enable true \ - --api.enabled-unsafe-cors true \ - --api.swagger true \ --home /app \ --minimum-gas-prices 0.015uluna \ --moniker localterra \ --p2p.upnp true \ - --rpc.laddr tcp://0.0.0.0:26657 \ No newline at end of file + --rpc.laddr tcp://0.0.0.0:26657 \ + --api.enable true \ + --api.swagger true \ + --api.enabled-unsafe-cors true diff --git a/docker-compose-reset b/docker-compose-reset new file mode 100755 index 0000000..729addb --- /dev/null +++ b/docker-compose-reset @@ -0,0 +1,5 @@ +#!/bin/sh + +docker-compose rm -f -s -v +docker volume rm localterra_terra +docker-compose build --no-cache \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 97df613..49bb694 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -16,6 +16,7 @@ services: - default ports: - "1317:1317" + - "8080:8080" - "9090:9090" - "9091:9091" - "26657:26657" diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 0000000..c2ced59 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +set -eux + +# Start the nginx process +nginx -g "daemon off;" & + +exec "$@" \ No newline at end of file diff --git a/initdb.d/init.sql b/initdb.d/init.sql deleted file mode 100644 index 7caba00..0000000 --- a/initdb.d/init.sql +++ /dev/null @@ -1,2 +0,0 @@ -CREATE DATABASE fcd; -CREATE DATABASE api; \ No newline at end of file diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..e6ade5d --- /dev/null +++ b/nginx.conf @@ -0,0 +1,44 @@ +events {} +http { + include mime.types; + default_type application/octet-stream; + + server { + listen 8080; + location / { + rewrite ^/$ /swagger/? permanent; + proxy_pass http://127.0.0.1:1317; + + if ($request_method = 'OPTIONS') { + add_header 'Access-Control-Allow-Origin' '*'; + # + # Om nom nom cookies + # + add_header 'Access-Control-Allow-Credentials' 'true'; + add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS'; + # + # Custom headers and headers various browsers *should* be OK with but aren't + # + add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,baggage,sentry-trace'; + # + # Tell client that this pre-flight info is valid for 20 days + # + add_header 'Access-Control-Max-Age' 1728000; + add_header 'Content-Type' 'text/plain charset=UTF-8'; + add_header 'Content-Length' 0; + return 204; + } + if ($request_method = 'POST') { + add_header 'Access-Control-Allow-Credentials' 'true'; + add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS'; + add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,baggage,sentry-trace'; + } + if ($request_method = 'GET') { + add_header 'Access-Control-Allow-Credentials' 'true'; + add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS'; + add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,baggage,sentry-trace'; + } + } + } +} +