From f1abbb0509cda524c24584256fe9e082b2756da4 Mon Sep 17 00:00:00 2001 From: Alexey Vasiliev Date: Sat, 6 Jul 2024 10:58:58 +0300 Subject: [PATCH] build --- .github/workflows/build-and-release.yml | 101 ++++-------------------- Dockerfile | 11 --- 2 files changed, 15 insertions(+), 97 deletions(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index a8adedf..9aed160 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -15,7 +15,7 @@ jobs: name: Build strategy: matrix: - os: [ubuntu-latest, macos-latest] + os: [ubuntu-latest] runs-on: ${{ matrix.os }} steps: - name: Checkout @@ -23,92 +23,21 @@ jobs: with: fetch-depth: 0 - - name: Set up Go - uses: actions/setup-go@v5 - with: - go-version: ${{ env.GO_VERSION }} - - - name: Install linux build packages - if: ${{ matrix.os == 'ubuntu-latest' }} - run: | - sudo apt-get update -qq && sudo apt-get install -yq --no-install-recommends \ - build-essential \ - curl \ - autoconf \ - automake \ - libtool \ - pkg-config - - - name: Install macos build packages - if: ${{ matrix.os == 'macos-latest' }} - run: | - brew install curl autoconf automake libtool pkg-config - - - name: Install libpostal - run: | - mkdir /tmp/libpostal_code - mkdir /tmp/libpostal_datadir - - - name: Install libpostal - run: git clone https://github.com/openvenues/libpostal - working-directory: /tmp/libpostal_code + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 - - name: Install libpostal - if: ${{ matrix.os == 'ubuntu-latest' }} - run: | - ./bootstrap.sh - ./configure --datadir=/tmp/libpostal_datadir - make -j4 - sudo make install - sudo ldconfig /usr/local/lib - working-directory: /tmp/libpostal_code/libpostal + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 - - name: Install libpostal - if: ${{ matrix.os == 'macos-latest' }} - run: | - ./bootstrap.sh - ./configure --datadir=/tmp/libpostal_datadir --disable-sse2 - make -j4 - sudo make install - working-directory: /tmp/libpostal_code/libpostal - - - name: CLI tests - run: | - go mod tidy - go test -v ./... - - - name: Setup Syft for SBOM - uses: anchore/sbom-action/download-syft@v0 - if: success() && startsWith(github.ref, 'refs/tags/') - - # - name: Import GPG key - # id: import_gpg - # uses: crazy-max/ghaction-import-gpg@v6 - # if: success() && startsWith(github.ref, 'refs/tags/') - # with: - # gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} - # passphrase: ${{ secrets.GPG_PASSPHRASE }} - - - name: Run GoReleaser - uses: goreleaser/goreleaser-action@v5 - if: ${{ matrix.os == 'ubuntu-latest' }} - # if: success() && startsWith(github.ref, 'refs/tags/') + - name: Login to Docker Hub + uses: docker/login-action@v3 with: - version: latest - args: release --clean --skip=publish --snapshot -f .goreleaser.linux.yml - # env: - # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - # HOMEBREW_TAP_GITHUB_TOKEN: ${{ secrets.HOMEBREW_TAP_GITHUB_TOKEN }} - # GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }} + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} - # - name: Run GoReleaser - # uses: goreleaser/goreleaser-action@v5 - # if: ${{ matrix.os == 'macos-latest' }} - # # if: success() && startsWith(github.ref, 'refs/tags/') - # with: - # version: latest - # args: release --clean --skip=publish --snapshot -f .goreleaser.macos.yml - # # env: - # # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - # # HOMEBREW_TAP_GITHUB_TOKEN: ${{ secrets.HOMEBREW_TAP_GITHUB_TOKEN }} - # # GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }} + - name: Build and push + uses: docker/build-push-action@v6 + with: + push: true + tags: user/app:latest diff --git a/Dockerfile b/Dockerfile index 024315b..dfdaa2a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -45,17 +45,6 @@ COPY . ./ # Build the binary. RUN go build -trimpath -ldflags="-s -w" -v -o postal_server -# Use the official Debian slim image for a lean production container. -# https://hub.docker.com/_/debian -# https://docs.docker.com/develop/develop-images/multistage-build/#use-multi-stage-builds -# FROM debian:bookworm-slim -# RUN set -x && apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \ -# ca-certificates && \ -# rm -rf /var/lib/apt/lists/* - -# Copy the binary to the production image from the builder stage. -# COPY --from=builder /app/postal_server /app/postal_server - EXPOSE 8000 # Run the web service on container startup. CMD ["/app/postal_server"]