diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..ae74b55 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,16 @@ +--- +version: 2 +updates: + - package-ecosystem: "docker" + directory: "/" + schedule: + interval: "weekly" + time: "09:00" + timezone: "Europe/Berlin" + + - package-ecosystem: "pip" + directory: "/" + schedule: + interval: "weekly" + time: "09:00" + timezone: "Europe/Berlin" diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..6c44df7 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,42 @@ +name: ci + +on: + pull_request: + +jobs: + docker-build: + runs-on: ubuntu-22.04 + steps: + - name: Checkout Code + uses: actions/checkout@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Docker metadata action + id: meta + uses: docker/metadata-action@v4 + with: + images: + cvdupdate-local + tags: | + type=raw,latest + + - name: Build Dockerimage + id: docker_build + uses: docker/build-push-action@v3 + with: + context: . + file: ./Dockerfile + labels: ${{ steps.meta.outputs.labels }} + outputs: type=docker,dest=/tmp/cvdupdate-local.tar + platforms: linux/amd64 + push: false + tags: ${{ steps.meta.outputs.tags }} + + - name: Run Dockerimage + run: | + docker load --input /tmp/cvdupdate-local.tar + docker run -d --net=host cvdupdate-local + sleep 30 + curl --fail --silent --output /dev/null http://localhost:8000/main.cvd diff --git a/.github/workflows/docker-release.yaml b/.github/workflows/docker-release.yaml new file mode 100644 index 0000000..1561e82 --- /dev/null +++ b/.github/workflows/docker-release.yaml @@ -0,0 +1,55 @@ +name: docker-release + +on: + push: + branches: + - main + tags: + - '*' + +jobs: + docker-build-push: + runs-on: ubuntu-22.04 + steps: + - name: Checkout Code + uses: actions/checkout@v3 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Login to Docker Hub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_PASSWORD }} + + - name: Docker metadata action + id: meta + uses: docker/metadata-action@v4 + with: + images: | + monotek/cvdupdate + tags: | + type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }} + type=ref,event=branch + type=ref,event=tag + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{major}} + + - name: Build and push + id: docker_build + uses: docker/build-push-action@v3 + with: + context: . + file: ./Dockerfile + labels: ${{ steps.meta.outputs.labels }} + platforms: linux/amd64,linux/arm64 + push: true + tags: ${{ steps.meta.outputs.tags }} + + - name: Image digest + run: echo ${{ steps.docker_build.outputs.digest }} diff --git a/.gitignore b/.gitignore old mode 100755 new mode 100644 diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..106bb07 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,17 @@ +FROM python:3.11.2-alpine3.17 + +WORKDIR /cvdupdate + +COPY . . + +RUN python setup.py build && \ + python setup.py install && \ + addgroup -g 1000 cvdupdate && \ + adduser -D -H -G cvdupdate -u 1000 -h /cvdupdate cvdupdate && \ + chown -R cvdupdate:cvdupdate /cvdupdate + +USER cvdupdate:cvdupdate + +RUN cvd update + +ENTRYPOINT ["cvd", "serve"]