Running Nginx with the ava client in the same docker container

This commit is contained in:
sevenzing 2020-07-19 14:17:48 +03:00 committed by GitHub
parent 578cc77195
commit cc9c155391
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 53 additions and 6 deletions

5
.dockerignore Normal file
View File

@ -0,0 +1,5 @@
.env*
docker-compose.yml
Dockerfile
README.md
LICENSE

11
.env.example Normal file
View File

@ -0,0 +1,11 @@
# Path to ava node
RPC_URL=http://localhost:9650/ext/bc/C/rpc
# Local path for url-request
LOCAL_URL=/rpc
# Local port for url-request
NGINX_PORT=4444
# Options for binary ava file
AVA_CMD_OPTIONS=--db-dir /db

1
.gitignore vendored
View File

@ -12,6 +12,7 @@ awscpu
*.dylib
*.profile
.env
# Test binary, build with `go test -c`
*.test

View File

@ -1,11 +1,16 @@
# syntax=docker/dockerfile:experimental
FROM golang:1.13.4-buster
FROM golang:1.13.4-buster AS builder
RUN mkdir -p /go/src/github.com/ava-labs
WORKDIR $GOPATH/src/github.com/ava-labs/
WORKDIR /src/github.com/ava-labs/
COPY . gecko
WORKDIR $GOPATH/src/github.com/ava-labs/gecko
WORKDIR /src/github.com/ava-labs/gecko
RUN ./scripts/build.sh
FROM nginx:latest
COPY --from=builder /src/github.com/ava-labs/gecko/build /build
COPY entrypoint.sh nginx.template ./
CMD ["/bin/bash", "entrypoint.sh"]

11
docker-compose.yml Normal file
View File

@ -0,0 +1,11 @@
version: "3"
services:
ava_node:
build: .
image: poanetwork/ava-node
volumes:
- ~/.gecko/db:/db
- ./nginx.template:/etc/nginx/conf.d/nginx.template
ports:
- ${NGINX_PORT}:${NGINX_PORT}
env_file: .env

8
entrypoint.sh Normal file
View File

@ -0,0 +1,8 @@
#!/bin/bash
echo "RECREATE NGINX CONFIG"
envsubst < /etc/nginx/conf.d/nginx.template > /etc/nginx/conf.d/default.conf
echo "START NGINX"
service nginx start
echo "START NODE WITH ARGS ${AVA_CMD_OPTIONS}"
./build/ava ${AVA_CMD_OPTIONS}

6
nginx.template Normal file
View File

@ -0,0 +1,6 @@
server {
listen ${NGINX_PORT};
location ${LOCAL_URL} {
proxy_pass ${RPC_URL};
}
}