diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml new file mode 100644 index 0000000..bb5a882 --- /dev/null +++ b/.github/workflows/docker-build.yml @@ -0,0 +1,38 @@ +name: Docker Build and Test + +on: + push: + tags: + - '*' + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Cache Docker layers + uses: actions/cache@v4 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx- + + # add docker hub secrets + - name: Log in to Docker Hub + uses: docker/login-action@v2 + with: + username: "mohamedelhabib" + password: ${{ secrets.DOCKER_TOKEN }} + + - name: Build Docker image + # build the image with the Dockerfile in the current directory and tag it with the git tag + run: docker build . --file Dockerfile --tag mohamedelhabib/docker-ajv:$GITHUB_REF_NAME + - name: Push Docker image + run: docker push mohamedelhabib/docker-ajv:$GITHUB_REF_NAME diff --git a/Dockerfile b/Dockerfile index 5000842..baee2b5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,9 @@ -FROM node:8-alpine - -ARG AJV_CLI_VERSION=3.2.1 -RUN npm install -g ajv-cli@${AJV_CLI_VERSION} +FROM node:24.4.1-alpine3.22 +ARG AJV_CLI_VERSION=5.0.0 +ARG AJV_FORMATS_VERSION=3.0.1 +RUN npm install -g ajv-cli@${AJV_CLI_VERSION} \ + && npm install -g ajv-formats@${AJV_FORMATS_VERSION} VOLUME ["/data"] WORKDIR "/data"