diff --git a/.github/workflows/release_publish_docker-image.yml b/.github/workflows/release_publish_docker-image.yml new file mode 100644 index 000000000..d8e1b9f92 --- /dev/null +++ b/.github/workflows/release_publish_docker-image.yml @@ -0,0 +1,62 @@ +name: Publish Docker image +on: + release: + types: + - released + - prereleased +jobs: + push_to_registry: + name: Push Docker image to Docker Hub + runs-on: ubuntu-latest + steps: + - + name: Check out the repo + uses: actions/checkout@v2 + - + name: Prepare + id: prep + run: | + DOCKER_IMAGE=crowdsecurity/crowdsec + VERSION=edge + if [[ $GITHUB_REF == refs/tags/* ]]; then + VERSION=${GITHUB_REF#refs/tags/} + elif [[ $GITHUB_REF == refs/heads/* ]]; then + VERSION=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's#/+#-#g') + elif [[ $GITHUB_REF == refs/pull/* ]]; then + VERSION=pr-${{ github.event.number }} + fi + TAGS="${DOCKER_IMAGE}:${VERSION}" + echo ::set-output name=docker_image::${DOCKER_IMAGE} + echo ::set-output name=version::${VERSION} + echo ::set-output name=tags::${TAGS} + echo ::set-output name=created::$(date -u +'%Y-%m-%dT%H:%M:%SZ') + - + name: Tag Latest + id: prep_tag_latest + if: "github.event.release.release" + run: | + TAGS=${{ steps.prep.outputs.tags }},${{ steps.prep.outputs.docker_image }}:latest + echo ::set-output name=tags::${TAGS} + echo ::set-output name=version::${{ steps.prep.outputs.version }} + echo ::set-output name=created::$(date -u +'%Y-%m-%dT%H:%M:%SZ') + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + - + name: Login to DockerHub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + - + name: Build and push + uses: docker/build-push-action@v2 + with: + context: . + file: ./Dockerfile + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.prep.outputs.tags }} + labels: | + org.opencontainers.image.source=${{ github.event.repository.html_url }} + org.opencontainers.image.created=${{ steps.prep.outputs.created }} + org.opencontainers.image.revision=${{ github.sha }} \ No newline at end of file diff --git a/README.md b/README.md index ba90b25c6..29aa431e4 100644 --- a/README.md +++ b/README.md @@ -95,6 +95,12 @@ cd crowdsec-v* sudo ./wizard.sh -i ``` +## :whale2: Docker + +You can use docker to run crowdsec, by using [official docker image](https://hub.docker.com/r/crowdsecurity/crowdsec). + +You can also build the docker image following [this](https://github.com/crowdsecurity/crowdsec/tree/master/docker#build) + ## ⚙️ Build it ! If you want to build crowdsec yourself follow these steps: