diff --git a/.dockerignore b/.dockerignore index 63051c9..4ce4c86 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,7 +1,6 @@ .DS_Store /target *.tar -build/ requests.sql template-v7.db diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 78c9f0a..2c5fb45 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -14,13 +14,13 @@ jobs: matrix: include: - binary: alisa - arch: linux/arm64 + mode: image - binary: elisa - arch: linux/amd64 + mode: binary - binary: elizabeth - arch: linux/arm64 + mode: image - binary: isabel - arch: linux/amd64 + mode: binary steps: - uses: actions/checkout@v4 @@ -32,28 +32,57 @@ jobs: id: buildx uses: docker/setup-buildx-action@master - - name: Build and push image + - name: Build image run: | IMAGE_ID=ghcr.io/chipp/${{ matrix.binary }} docker buildx build . --file bin/${{ matrix.binary }}/Dockerfile \ - --push \ - --platform ${{ matrix.arch }} \ + --load \ + --progress plain \ --tag $IMAGE_ID:latest \ --build-arg VERSION="0.1.${{ github.run_number }}" \ - --label "org.opencontainers.image.source=https://github.com/${{ github.repository }}" \ --cache-from=type=registry,ref=$IMAGE_ID:cache \ --cache-to=type=registry,ref=$IMAGE_ID:cache,mode=max + docker ps -a + + - name: Compose arm64 runnable image + if: matrix.mode == 'image' + run: | + docker ps -a + + docker run --rm -v "$PWD/build:/build" ghcr.io/chipp/${{ matrix.binary }}:latest \ + cp /root/${{ matrix.binary }} /build/${{ matrix.binary }} + + docker buildx build . --file conf/arm64.Dockerfile \ + --push \ + --progress plain \ + --tag $IMAGE_ID:latest \ + --build-arg BINARY=${{ matrix.binary }} \ + --label "org.opencontainers.image.source=https://github.com/${{ github.repository }}" + + - name: Extract arm64 binary + if: matrix.mode == 'binary' + run: | + docker ps -a + + docker run --rm -v "$PWD/build:/build" ghcr.io/chipp/${{ matrix.binary }}:latest \ + cp /root/${{ matrix.binary }} /build/${{ matrix.binary }} + + - name: Archive arm64 artifact + if: matrix.mode == 'binary' + uses: actions/upload-artifact@v4 + with: + name: ${{ matrix.binary }} + path: build/${{ matrix.binary }} + retention-days: 1 + deploy: runs-on: ubuntu-latest needs: push steps: - uses: actions/checkout@v4 - - name: Log into registry - run: echo ${{ secrets.CR_PAT }} | docker login ghcr.io -u $GITHUB_ACTOR --password-stdin - - name: Add ssh key run: | mkdir ~/.ssh/ @@ -85,13 +114,15 @@ jobs: ssh github@ezio.chipp.dev \ "cd /web/lisa && docker compose down --remove-orphans --rmi all && docker compose up -d" - - name: Extract elisa - run: | - docker run --rm -v "$PWD/build:/build" ghcr.io/chipp/elisa:latest cp /root/elisa /build/elisa + - name: Download elisa + uses: actions/download-artifact@v4 + with: + name: elisa - - name: Extract isabel - run: | - docker run --rm -v "$PWD/build:/build" ghcr.io/chipp/isabel:latest cp /root/isabel /build/isabel + - name: Download isabel + uses: actions/download-artifact@v4 + with: + name: isabel - name: Deploy elisa and isabel run: | @@ -104,5 +135,5 @@ jobs: ssh -v chipp@pi3.chipp.dev "echo test" ssh chipp@pi3.chipp.dev "sudo service elisa stop && sudo service isabel stop" - scp build/elisa build/isabel chipp@pi3.chipp.dev:/usr/local/bin + scp elisa isabel chipp@pi3.chipp.dev:/usr/local/bin ssh chipp@pi3.chipp.dev "sudo service elisa start && sudo service isabel start" diff --git a/bin/alisa/Dockerfile b/bin/alisa/Dockerfile index 6c91ab5..8e9e76f 100644 --- a/bin/alisa/Dockerfile +++ b/bin/alisa/Dockerfile @@ -1,4 +1,4 @@ -FROM ghcr.io/chipp/build.rust.arm64_musl:1.76.0_1 AS builder +FROM ghcr.io/chipp/build.rust.arm64_musl:1.76.0_1 WORKDIR /home/rust/src RUN USER=rust \ @@ -50,17 +50,3 @@ RUN sed -i "s/version = \"0.1.0\"/version = \"${VERSION}\"/g" bin/alisa/Cargo.to RUN cargo build --release -p alisa && \ mv target/aarch64-unknown-linux-musl/release/alisa ./ && \ rm -rf target/aarch64-unknown-linux-musl/release/ target/release/ - -FROM alpine:3.18.4 -RUN apk --no-cache add ca-certificates && update-ca-certificates -RUN apk --no-cache add tzdata && \ - cp /usr/share/zoneinfo/Europe/Vilnius /etc/localtime && \ - echo "Europe/Vilnius" > /etc/timezone && \ - apk del tzdata - -WORKDIR /root/ -ENV SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt -ENV SSL_CERT_DIR=/etc/ssl/certs -ENV RUST_BACKTRACE=full - -COPY --from=0 /home/rust/src/alisa . diff --git a/conf/arm64.Dockerfile b/conf/arm64.Dockerfile new file mode 100644 index 0000000..d4065fe --- /dev/null +++ b/conf/arm64.Dockerfile @@ -0,0 +1,17 @@ +FROM alpine:3.19.1 + +RUN apk --no-cache add ca-certificates && update-ca-certificates +RUN apk --no-cache add tzdata && \ + cp /usr/share/zoneinfo/Europe/Vilnius /etc/localtime && \ + echo "Europe/Vilnius" > /etc/timezone && \ + apk del tzdata + +WORKDIR /root/ +ENV SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt +ENV SSL_CERT_DIR=/etc/ssl/certs +ENV RUST_BACKTRACE=full + +ARG BINARY + +COPY build/${BINARY} . +CMD [ "${BINARY}" ]