From 64a3b9a3577bb0f2bf57abc7d22d2ded44fb4b68 Mon Sep 17 00:00:00 2001 From: jaywcjlove <398188662@qq.com> Date: Mon, 11 Jul 2022 12:50:43 +0800 Subject: [PATCH] feat: add docker config. --- .github/workflows/ci.yml | 65 +++++++++++++++++++++++++++++++++++++--- Dockerfile | 7 +++++ README.md | 1 + 3 files changed, 69 insertions(+), 4 deletions(-) create mode 100644 Dockerfile diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a0011cd..385153d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,13 +25,13 @@ jobs: - name: Create Tag id: create_tag - uses: jaywcjlove/create-tag-action@v1.3.6 + uses: jaywcjlove/create-tag-action@v1.3.8 with: package-path: ./package.json - name: get tag version id: tag_version - uses: jaywcjlove/changelog-generator@v1.5.3 + uses: jaywcjlove/changelog-generator@v1.5.7 - name: Deploy Website uses: peaceiris/actions-gh-pages@v3 @@ -45,7 +45,7 @@ jobs: - name: Generate Changelog id: changelog - uses: jaywcjlove/changelog-generator@v1.5.3 + uses: jaywcjlove/changelog-generator@v1.5.7 with: token: ${{ secrets.GITHUB_TOKEN }} filter-author: (jaywcjlove|小弟调调™|dependabot\[bot\]|Renovate Bot) @@ -62,4 +62,61 @@ jobs: Documentation ${{ steps.changelog.outputs.tag }}: https://raw.githack.com/jaywcjlove/html-tutorial/${{ steps.changelog.outputs.gh-pages-short-hash }}/index.html Comparing Changes: ${{ steps.changelog.outputs.compareurl }} - ${{ steps.changelog.outputs.changelog }} \ No newline at end of file + ${{ steps.changelog.outputs.changelog }} + + + ## Docker + + [![Docker Image Version (latest by date)](https://img.shields.io/docker/v/wcjiang/c-tutorial?logo=docker)](https://hub.docker.com/r/wcjiang/c-tutorial) + + ```bash + docker pull wcjiang/c-tutorial:${{steps.changelog.outputs.version}} + ``` + + ```bash + docker run --name c-tutorial --rm -d -p 9883:3000 wcjiang/c-tutorial:${{steps.changelog.outputs.version}} + # Or + docker run --name c-tutorial -itd -p 9883:3000 wcjiang/c-tutorial:${{steps.changelog.outputs.version}} + ``` + + Visit the following URL in your browser + + ```bash + http://localhost:9883/ + ``` + + + # Create Docker Image + - name: Docker login + if: steps.create_tag.outputs.successful + run: docker login -u ${{ secrets.DOCKER_USER }} -p ${{ secrets.DOCKER_PASSWORD }} + + - name: Build Awesome Mac image + if: steps.create_tag.outputs.successful + run: docker image build -t c-tutorial . + + - name: Tags & Push image + if: steps.create_tag.outputs.successful + run: | + echo "outputs.tag - ${{ steps.changelog.outputs.version }}" + docker tag c-tutorial ${{ secrets.DOCKER_USER }}/c-tutorial:${{steps.changelog.outputs.version}} + docker tag c-tutorial ${{ secrets.DOCKER_USER }}/c-tutorial:latest + docker push ${{ secrets.DOCKER_USER }}/c-tutorial:${{steps.changelog.outputs.version}} + docker push ${{ secrets.DOCKER_USER }}/c-tutorial:latest + + # Create Docker Image in GitHub + - name: Login to GitHub registry + run: echo ${{ github.token }} | docker login ghcr.io -u ${{ github.actor }} --password-stdin + + - name: Build docker image + run: docker build -t ghcr.io/jaywcjlove/c-tutorial:latest . + + - name: Publish to GitHub registry + run: docker push ghcr.io/jaywcjlove/c-tutorial:latest + + - name: Tag docker image (beta) and publish to GitHub registry + if: steps.create_tag.outputs.successful + run: | + echo "version: v${{ steps.changelog.outputs.version }}" + docker tag ghcr.io/jaywcjlove/c-tutorial:latest ghcr.io/jaywcjlove/c-tutorial:${{steps.changelog.outputs.version}} + docker push ghcr.io/jaywcjlove/c-tutorial:${{steps.changelog.outputs.version}} \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..b740ca1 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,7 @@ +# https://lipanski.com/posts/smallest-docker-image-static-website +# https://github.com/lipanski/docker-static-website +FROM lipanski/docker-static-website:latest + +# Copy the static website +# Use the .dockerignore file to control what ends up inside the image! +COPY ./dist . \ No newline at end of file diff --git a/README.md b/README.md index dbcc133..e11f8ed 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,7 @@ C Tutorial === [![CI](https://github.com/jaywcjlove/c-tutorial/actions/workflows/ci.yml/badge.svg)](https://github.com/jaywcjlove/c-tutorial/actions/workflows/ci.yml) +[![Docker Image Version (latest by date)](https://img.shields.io/docker/v/wcjiang/c-tutorial?logo=docker)](https://hub.docker.com/r/wcjiang/c-tutorial) C 语言是一种功能强大、简洁的计算机语言,通过它可以编写程序,指挥计算机完成指定任务。