|
9 | 9 | REGISTRY_IMAGE: ghcr.io/stackhpc/danswer/danswer-web-server |
10 | 10 |
|
11 | 11 | jobs: |
12 | | - build: |
| 12 | + build-and-push: |
13 | 13 | runs-on: ubuntu-latest |
14 | | - strategy: |
15 | | - fail-fast: false |
16 | | - matrix: |
17 | | - platform: |
18 | | - - linux/amd64 |
19 | | - # - linux/arm64 |
20 | 14 |
|
21 | 15 | steps: |
22 | | - - name: Prepare |
23 | | - run: | |
24 | | - platform=${{ matrix.platform }} |
25 | | - echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV |
26 | | -
|
27 | | - - name: Checkout |
28 | | - uses: actions/checkout@v4 |
29 | | - |
30 | | - - name: Docker meta |
31 | | - id: meta |
32 | | - uses: docker/metadata-action@v5 |
33 | | - with: |
34 | | - images: ${{ env.REGISTRY_IMAGE }} |
35 | | - tags: | |
36 | | - type=raw,value=${{ env.REGISTRY_IMAGE }}:${{ github.ref_name }} |
37 | | - type=raw,value=${{ env.REGISTRY_IMAGE }}:latest |
38 | | -
|
39 | | - - name: Set up Docker Buildx |
40 | | - uses: docker/setup-buildx-action@v3 |
41 | | - |
42 | | - - name: Login to GitHub Container Registry |
43 | | - uses: docker/login-action@v3 |
44 | | - with: |
45 | | - registry: ghcr.io |
46 | | - username: ${{ github.actor }} |
47 | | - password: ${{ secrets.GITHUB_TOKEN }} |
48 | | - |
49 | | - - name: Build and push by digest |
50 | | - id: build |
51 | | - uses: docker/build-push-action@v5 |
52 | | - with: |
53 | | - context: ./web |
54 | | - file: ./web/Dockerfile |
55 | | - platforms: ${{ matrix.platform }} |
56 | | - push: true |
57 | | - build-args: | |
58 | | - DANSWER_VERSION=${{ github.ref_name }} |
59 | | - # needed due to weird interactions with the builds for different platforms |
60 | | - no-cache: true |
61 | | - labels: ${{ steps.meta.outputs.labels }} |
62 | | - outputs: type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true |
63 | | - |
64 | | - - name: Export digest |
65 | | - run: | |
66 | | - mkdir -p /tmp/digests |
67 | | - digest="${{ steps.build.outputs.digest }}" |
68 | | - touch "/tmp/digests/${digest#sha256:}" |
69 | | -
|
70 | | - - name: Upload digest |
71 | | - uses: actions/upload-artifact@v4 |
72 | | - with: |
73 | | - name: digests-${{ env.PLATFORM_PAIR }} |
74 | | - path: /tmp/digests/* |
75 | | - if-no-files-found: error |
76 | | - retention-days: 1 |
77 | | - |
78 | | - merge: |
79 | | - runs-on: ubuntu-latest |
80 | | - needs: |
81 | | - - build |
82 | | - steps: |
83 | | - - name: Download digests |
84 | | - uses: actions/download-artifact@v4 |
85 | | - with: |
86 | | - path: /tmp/digests |
87 | | - pattern: digests-* |
88 | | - merge-multiple: true |
89 | | - |
90 | | - - name: Set up Docker Buildx |
91 | | - uses: docker/setup-buildx-action@v3 |
92 | | - |
93 | | - - name: Docker meta |
94 | | - id: meta |
95 | | - uses: docker/metadata-action@v5 |
96 | | - with: |
97 | | - images: ${{ env.REGISTRY_IMAGE }} |
98 | | - |
99 | | - - name: Login to GitHub Container Registry |
100 | | - uses: docker/login-action@v3 |
101 | | - with: |
102 | | - registry: ghcr.io |
103 | | - username: ${{ github.actor }} |
104 | | - password: ${{ secrets.GITHUB_TOKEN }} |
105 | | - |
106 | | - - name: Create manifest list and push |
107 | | - working-directory: /tmp/digests |
108 | | - run: | |
109 | | - docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ |
110 | | - $(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *) |
111 | | -
|
112 | | - - name: Inspect image |
113 | | - run: | |
114 | | - docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }} |
115 | | -
|
116 | | - - name: Run Trivy vulnerability scanner |
117 | | - uses: aquasecurity/trivy-action@master |
118 | | - with: |
119 | | - image-ref: ${{ env.REGISTRY_IMAGE }}:${{ github.ref_name }} |
120 | | - severity: 'CRITICAL,HIGH' |
| 16 | + - name: Checkout code |
| 17 | + uses: actions/checkout@v4 |
| 18 | + |
| 19 | + - name: Set up Docker Buildx |
| 20 | + uses: docker/setup-buildx-action@v3 |
| 21 | + |
| 22 | + - name: Login to GitHub Container Registry |
| 23 | + uses: docker/login-action@v3 |
| 24 | + with: |
| 25 | + registry: ghcr.io |
| 26 | + username: ${{ github.actor }} |
| 27 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 28 | + |
| 29 | + - name: Docker meta |
| 30 | + id: meta |
| 31 | + uses: docker/metadata-action@v5 |
| 32 | + with: |
| 33 | + images: ${{ env.REGISTRY_IMAGE }} |
| 34 | + tags: | |
| 35 | + type=raw,value=${{ github.ref_name }} |
| 36 | + type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }} |
| 37 | +
|
| 38 | + - name: Web Image Docker Build and Push |
| 39 | + uses: docker/build-push-action@v5 |
| 40 | + with: |
| 41 | + context: ./web |
| 42 | + file: ./web/Dockerfile |
| 43 | + platforms: linux/amd64 #,linux/arm64 |
| 44 | + push: true |
| 45 | + tags: ${{ steps.meta.outputs.tags }} |
| 46 | + build-args: | |
| 47 | + DANSWER_VERSION=${{ github.ref_name }} |
| 48 | + cache-from: type=registry,ref=${{ env.REGISTRY_IMAGE }}:buildcache |
| 49 | + cache-to: type=registry,ref=${{ env.REGISTRY_IMAGE}}:buildcache,mode=max |
| 50 | + |
| 51 | + - name: Run Trivy vulnerability scanner |
| 52 | + uses: aquasecurity/trivy-action@master |
| 53 | + with: |
| 54 | + # To run locally: trivy image --severity HIGH,CRITICAL danswer/danswer-web |
| 55 | + image-ref: ${{ env.REGISTRY_IMAGE }}:${{ github.ref_name }} |
| 56 | + severity: 'CRITICAL,HIGH' |
0 commit comments