-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding security in Docker container with ci cd
- Loading branch information
1 parent
2fc891e
commit 51d3375
Showing
8 changed files
with
99 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,15 +3,13 @@ name: Ci and Cd | |
on: | ||
push: | ||
branches: | ||
- develop | ||
- main | ||
- fixenv | ||
- "*" | ||
|
||
jobs: | ||
develop: | ||
linting: | ||
name: Test and linting | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repo | ||
uses: actions/checkout@v4 | ||
|
@@ -29,34 +27,56 @@ jobs: | |
working-directory: ./project | ||
run: npm run lint | ||
|
||
staging: | ||
build: | ||
name: Push to docker hub | ||
runs-on: ubuntu-22.04 | ||
if: ${{github.ref == 'refs/heads/fixenv'}} | ||
needs: linting | ||
if: ${{github.ref == 'refs/heads/main'}} || ${{github.ref == 'refs/heads/develop'}} | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Linting Dockerfile | ||
uses: hadolint/[email protected] | ||
with: | ||
dockerfile: Dockerfile | ||
verbose: true | ||
format: json | ||
|
||
|
||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v3 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Login into docker hub | ||
uses: docker/login-action@v3 | ||
with: | ||
username: ${{secrets.DOCKER_USERNAME}} | ||
password: ${{secrets.DOCKER_PASSWORD}} | ||
|
||
- name: Deploy frontend app to dockerhub | ||
env: | ||
DOCKER_CONTENT_TRUST: 1 | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: "{{defaultContext}}:project" | ||
push: true | ||
push: false | ||
tags: ${{secrets.DOCKER_USERNAME}}/portofolio:${{secrets.DOCKER_PORTOFOLIO_TAGS_APP}} | ||
secrets: | | ||
"VITE_SERVICE_ID=${{secrets.VITE_SERVICE_ID}}" | ||
"VITE_PUBLIC_KEY=${{secrets.VITE_PUBLIC_KEY}}" | ||
"VITE_TEMPLATE_ID=${{secrets.VITE_TEMPLATE_ID}}" | ||
"VITE_TEMPLATE_ID=${{secrets.VITE_TEMPLATE_ID}}" | ||
- name: Run Trivy vulnerability scanner in fs mode | ||
uses: aquasecurity/[email protected] | ||
with: | ||
scan-type: 'image' | ||
scan-ref: ${{secrets.DOCKER_USERNAME}}/portofolio:${{secrets.DOCKER_PORTOFOLIO_TAGS_APP}} | ||
trivy-config: trivy.yaml | ||
|
||
- name: Login into docker hub | ||
uses: docker/login-action@v3 | ||
with: | ||
username: ${{secrets.DOCKER_USERNAME}} | ||
password: ${{secrets.DOCKER_PASSWORD}} | ||
|
||
- name: Push Docker image to Docker Hub | ||
run: | | ||
docker push ${{ secrets.DOCKER_USERNAME }}/portofolio:${{ secrets.DOCKER_PORTOFOLIO_TAGS_APP }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
format: table | ||
exit-code: 1 | ||
severity: CRITICAL | ||
ignore-unfixed: false | ||
vuln-type: 'os, library' |