diff --git a/.github/workflows/buiild.yml b/.github/workflows/buiild.yml index 2f8380e..48461d8 100644 --- a/.github/workflows/buiild.yml +++ b/.github/workflows/buiild.yml @@ -18,7 +18,6 @@ jobs: run: | # tag is branch name or tag if there is a tag echo ::set-output name=image_tag::${GITHUB_REF##*/} - echo ::set-output name=do_push::true - name: Cache Docker layers uses: actions/cache@v3 @@ -39,23 +38,13 @@ jobs: id: buildx uses: docker/setup-buildx-action@v3 - - name: Build developer image + - name: Build image uses: docker/build-push-action@v5 with: builder: ${{ steps.buildx.outputs.name }} - push: ${{ steps.tag.outputs.do_push }} + push: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags') }} tags: | ghcr.io/${{ github.repository }}:latest ghcr.io/${{ github.repository }}:${{ steps.tag.outputs.image_tag }} - # - name: Build runtime image - # uses: docker/build-push-action@v5 - # with: - # builder: ${{ steps.buildx.outputs.name }} - # push: ${{ steps.tag.outputs.do_push }} - # tags: | - # ghcr.io/${{ github.repository }}:${{ steps.tag.outputs.image_tag }}.run - # target: runtime - # cache-from: type=local,src=/tmp/.buildx-cache - # cache-to: type=local,dest=/tmp/.buildx-cache diff --git a/Dockerfile b/Dockerfile index 9e194d5..3c8261b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,10 +9,12 @@ RUN git clone https://github.com/neilpa/yajsv.git && \ cd yajsv && \ git checkout 9889895863c595d38aa5d6347dfadb99f2687a51^{commit} -RUN cd /go/yajsv && go build -o /yajsv +# use turn off cgo to build a static binary +ENV CGO_ENABLED=0 +RUN cd yajsv && go build -o /yajsv.bin FROM alpine:3.18.4 as runtime -COPY --from=build /yajsv /yajsv +COPY --from=build /yajsv.bin /yajsv ENTRYPOINT ["/yajsv"]