From 90acabfdd741a98bd3232d2439a1aa96516c321e Mon Sep 17 00:00:00 2001 From: Tornado Contrib Date: Thu, 11 Apr 2024 23:49:27 +0000 Subject: [PATCH] Improve docker file --- Dockerfile | 5 +++-- docker-compose.yml | 11 +++++++++-- maticgasstation.Dockerfile | 5 ++++- package.json | 2 +- 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index d9a7265..e803fd2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,9 +3,10 @@ WORKDIR /app COPY ["package.json", "yarn.lock", "./"] -RUN npm i -g yarn && yarn +RUN yarn COPY . . -EXPOSE 7000 +RUN yarn build + ENTRYPOINT ["yarn", "start"] \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 5e7b24a..b5a9dfe 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -19,6 +19,12 @@ services: dockerfile: maticgasstation.Dockerfile expose: - '127.0.0.1:7000:7000' + healthcheck: + test: ["CMD-SHELL", "curl http://localhost:7000/v2"] + interval: 10s + timeout: 5s + retries: 5 + start_period: 10s gaspriceoracle: container_name: gaspriceoracle @@ -29,5 +35,6 @@ services: - ./docker.env build: context: . - expose: - - '127.0.0.1:7000:7000' \ No newline at end of file + depends_on: + maticgasstation: + condition: service_healthy \ No newline at end of file diff --git a/maticgasstation.Dockerfile b/maticgasstation.Dockerfile index a6f6a71..4beaca9 100644 --- a/maticgasstation.Dockerfile +++ b/maticgasstation.Dockerfile @@ -14,10 +14,13 @@ RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && \ ENV REPO=https://github.com/maticnetwork/maticgasstation ENV VERSION=ca8c49c24de98dedac7196b1b07068feeebe856a -RUN git clone $REPO --branch $VERSION && \ +RUN git clone $REPO && \ cd maticgasstation && \ + git checkout $VERSION && \ npm i +WORKDIR /root/maticgasstation + EXPOSE 7000 ENTRYPOINT ["node", "src/index.js"] \ No newline at end of file diff --git a/package.json b/package.json index 394064e..006b779 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "types": "tsc --declaration --emitDeclarationOnly", "compile": "hardhat compile && hardhat flatten:all", "build": "yarn compile && yarn types", - "start": "yarn build && ts-node ./src/index.ts", + "start": "ts-node ./src/index.ts", "lint": "eslint . --ext .ts --ignore-pattern typechain-types" }, "files": [