diff --git a/.github/workflows/docker-build-push.yml b/.github/workflows/docker-build-push.yml new file mode 100644 index 0000000..d7760ef --- /dev/null +++ b/.github/workflows/docker-build-push.yml @@ -0,0 +1,53 @@ +name: Docker (Build and Push) + +# Controls when the workflow will run +on: + push: + tags: + - 'v*.*.*' + +# permissions are needed if pushing to ghcr.io +permissions: + packages: write + +jobs: + build_push: + name: Build and Push + runs-on: ubuntu-latest + steps: + # Get the repository's code + - uses: actions/checkout@v4 + # https://github.com/docker/setup-qemu-action + - uses: docker/setup-qemu-action@v3 + # https://github.com/docker/setup-buildx-action + - uses: docker/setup-buildx-action@v3 + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + # list of Docker images to use as base name for tags + images: | + ghcr.io/muratovas/docker-network-graph + # Docker tags based on the following events/attributes + tags: | + type=ref,event=branch + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{major}} + type=sha + + - name: Build and Push + uses: docker/build-push-action@v5 + with: + context: . + platforms: linux/amd64,linux/arm64 + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml deleted file mode 100644 index f87ecc0..0000000 --- a/.github/workflows/docker.yml +++ /dev/null @@ -1,60 +0,0 @@ -name: Publish Docker image -on: - push: - branches: - - '**' - tags: - - 'v*' -jobs: - push_to_registry: - name: Build and push docker image - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Docker meta - id: docker_meta - uses: docker/metadata-action@v4 - with: - images: ${{ secrets.DOCKERHUB_USERNAME }}/docker-network-graph,ghcr.io/${{ github.repository_owner }}/docker-network-graph - tags: | - type=ref,event=branch - type=semver,pattern={{version}} - type=semver,pattern={{major}}.{{minor}} - - name: Checkout - uses: actions/checkout@v3 - - name: Set up QEMU - uses: docker/setup-qemu-action@v1 - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - - name: Cache Docker layers - if: github.event_name != 'pull_request' - uses: actions/cache@v3 - with: - path: /tmp/.buildx-cache - key: ${{ runner.os }}-buildx-${{ github.sha }} - restore-keys: | - ${{ runner.os }}-buildx- - - name: Login to DockerHub - uses: docker/login-action@v1 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Login to GitHub Container Registry - if: github.event_name != 'pull_request' - uses: docker/login-action@v1 - with: - registry: ghcr.io - username: ${{ github.repository_owner }} - password: ${{ secrets.GITHUB_TOKEN }} - - name: Build and push - uses: docker/build-push-action@v2 - with: - context: . - file: ./Dockerfile - platforms: linux/amd64,linux/386,linux/arm/v6,linux/arm/v7,linux/arm64 - push: True - tags: ${{ steps.docker_meta.outputs.tags }} - labels: ${{ steps.docker_meta.outputs.labels }} - cache-from: type=local,src=/tmp/.buildx-cache - cache-to: type=local,dest=/tmp/.buildx-cache diff --git a/README.md b/README.md index 0eeefcb..f254e2a 100644 --- a/README.md +++ b/README.md @@ -13,21 +13,23 @@ Changes: ![example graph](./example.png) ## Usage +```bash usage: docker-network-graph.py [-h] [-v] [-o OUT] [-u] - Visualize docker networks. - optional arguments: -h, --help Show this help message and exit -v, --verbose Verbose output -o OUT, --out OUT Write output to file [not supported by container] -u, --url Generate link for GraphvizOnline +``` ## Running inside docker If you want to generate a graph for a remote system you can also easily run this script inside a pre-built docker container: - - docker run --rm -v /var/run/docker.sock:/var/run/docker.sock e-dant/docker-network-graph -u + +```bash +docker run --rm -v /var/run/docker.sock:/var/run/docker.sock muratovas/docker-network-graph -u +``` For more advanced use cases you can append arguments to the `docker run` command as if you were running it in a local shell. @@ -35,10 +37,12 @@ command as if you were running it in a local shell. ## Running local In most cases what you want to run are the following couple commands: - git clone https://github.com/e-dant/docker-network-graph.git - cd docker-network-graph - pipenv install - pipenv run python docker-network-graph.py -o output.svg +```bash +git clone https://github.com/muratovas/docker-network-graph.git +cd docker-network-graph +pipenv install +pipenv run python docker-network-graph.py -o output.svg +``` This will generate an .svg file containing the graph. @@ -58,5 +62,7 @@ using dummy containers in `test`. You can deploy it using `docker-compose -f docker-compose.yml up -d`. ## Credit + [dot lang](https://www.graphviz.org/doc/info/lang.html) + [gvonline](https://dreampuf.github.io/GraphvizOnline/)