feat: create Docker image, set up Docker CI #528
22
.github/workflows/build.yml
vendored
22
.github/workflows/build.yml
vendored
@ -19,24 +19,4 @@ jobs:
|
||||
- run: cp config.json.example config.json
|
||||
|
||||
- run: echo '{"version":"","buildLabel":"","matchmakingBuildId":""}' > static/data/buildConfig.json
|
||||
- run: npm run build
|
||||
- run: npm run lint
|
||||
docker:
|
||||
runs-on: ubuntu-latest
|
||||
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
|
||||
steps:
|
||||
- name: Set up Docker buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
- name: Log in to container registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
platforms: linux/amd64,linux/arm64
|
||||
push: true
|
||||
tags: |
|
||||
ghcr.io/${{ github.repository }}:latest
|
||||
ghcr.io/${{ github.repository}}:${{ github.sha }}
|
||||
- run: npm run lint
|
26
.github/workflows/docker.yml
vendored
Normal file
26
.github/workflows/docker.yml
vendored
Normal file
@ -0,0 +1,26 @@
|
||||
name: Build Docker image
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
pull_request: {}
|
||||
jobs:
|
||||
docker:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Set up Docker buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
- name: Log in to container registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
platforms: linux/amd64,linux/arm64
|
||||
push: true
|
||||
tags: |
|
||||
ghcr.io/${{ github.repository }}:latest
|
||||
ghcr.io/${{ github.repository}}:${{ github.sha }}
|
Loading…
x
Reference in New Issue
Block a user
⚠️ Potential issue
Adjust image tagging and add checkout step.
While the multi-platform build and push configuration is good, there are a few issues to address:
ghcr.io/<owner>/<repo>
.Please make the following changes:
tags
field in the "Build and push" step:context
field to specify the build context:These changes will ensure correct image tagging and provide the necessary build context.
🛠️ Refactor suggestion
Consider adding conditions for running the Docker job.
The new
docker
job is a valuable addition to the workflow. To optimize CI/CD pipeline efficiency, consider adding conditions to control when this job runs. For example:This condition would run the Docker job only for pushes to the main branch, which is typically when you want to build and push new Docker images. Adjust the condition as needed based on your branching and release strategy.
💡 Codebase verification
Action Required: Add a Checkout Step to the Workflow
The build and push step is missing a checkout step. Please add a checkout step before the build and push step to ensure the repository code is available for the Docker build process.
🔗 Analysis chain
LGTM with a minor concern: Build and push configuration.
The build and push step is well-configured:
docker/build-push-action
.However, there's one potential issue:
There's no explicit checkout step before this build step. While some actions automatically check out the repository, it's generally safer to include an explicit checkout step to ensure the correct code is available for the build context.
Consider adding a checkout step at the beginning of the job:
This will ensure that the correct code is available for the Docker build process.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
Length of output: 177