Skip to content

Commit

Permalink
try to improve docker
Browse files Browse the repository at this point in the history
  • Loading branch information
Arvolear committed Oct 31, 2024
1 parent 7d58e3f commit 94b30ea
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 41 deletions.
23 changes: 10 additions & 13 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
node_modules
.DS_Store
.idea
.vscode
.npm
.eslintcache

# Hardhat files
artifacts
coverage.json
coverage
Dockerfile
.git
.gitignore
.env
.editorconfig

# Compilation output
/build-test/
/dist

# Coverage
.nyc_output

# Below is Github's node gitignore template,
# ignoring the node_modules part, as it'd ignore every node_modules, and we have some for testing
coverage.json
coverage

# Logs
logs
Expand All @@ -33,8 +35,3 @@ pids

# node-waf configuration
.lock-wscript

# Optional npm cache directory
.npm

!src/**/artifacts
13 changes: 5 additions & 8 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,11 @@ jobs:
- name: Checkout the repository
uses: actions/checkout@v3

- name: Set up Docker Buildx
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Build Docker Image and Run Tests
run: docker build --build-arg NODE_VERSION=${{ matrix.node }} -t hardhat-zkit-node${{ matrix.node }} --progress=plain --no-cache .
- name: Build Docker image
run: docker build --build-arg NODE_VERSION=${{ matrix.node }} -t hardhat-zkit-node${{ matrix.node }} --progress=plain .

- name: Cleanup Docker resources
run: |
docker rmi hardhat-zkit-node${{ matrix.node }} --force
docker buildx prune -a -f
docker system prune -a -f --volumes
- name: Run tests
run: docker run --rm hardhat-zkit-node${{ matrix.node }} test-local
15 changes: 7 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
node_modules
.DS_Store
.idea
.vscode
.eslintcache
.env
.npm

# Hardhat files
artifacts
coverage.json
coverage

# Compilation output
/build-test/
/dist

# Coverage
.nyc_output

# Below is Github's node gitignore template,
# ignoring the node_modules part, as it'd ignore every node_modules, and we have some for testing
coverage.json
coverage

# Logs
logs
Expand All @@ -38,7 +39,5 @@ pids
typings/
**/.storage.json

# Optional npm cache directory
.npm

# Exclude
!src/**/artifacts
16 changes: 9 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
ARG NODE_VERSION=20

FROM node:${NODE_VERSION}

FROM node:${NODE_VERSION} AS base
WORKDIR /hardhat-zkit

COPY . .

RUN npm install
FROM base AS install
RUN mkdir -p /temp/dev
COPY package.json package-lock.json /temp/dev/
RUN cd /temp/dev && npm ci

ARG RUN_TESTS=true
FROM base AS dev
COPY --from=install /temp/dev/node_modules node_modules
COPY . .

RUN if [ "$RUN_TESTS" = "true" ]; then npm run test-local; fi
ENTRYPOINT ["npm", "run"]
5 changes: 2 additions & 3 deletions scripts/coverage-docker.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env bash

docker build --build-arg RUN_TESTS=false -t hardhat-zkit --progress=plain --no-cache .
docker run --rm -v $(pwd)/coverage:/hardhat-zkit/coverage hardhat-zkit npm run coverage-local
docker rmi hardhat-zkit --force
docker build -t hardhat-zkit --progress=plain .
docker run --rm -v $(pwd)/coverage:/hardhat-zkit/coverage hardhat-zkit coverage-local
4 changes: 2 additions & 2 deletions scripts/test-docker.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env bash

docker build -t hardhat-zkit --progress=plain --no-cache .
docker rmi hardhat-zkit --force
docker build -t hardhat-zkit --progress=plain .
docker run --rm hardhat-zkit test-local

0 comments on commit 94b30ea

Please sign in to comment.