From ee94cb2ec905fd74e0263da54a1aa79d3f8f404f Mon Sep 17 00:00:00 2001 From: dmnbars Date: Wed, 9 Jun 2021 23:42:19 +0300 Subject: [PATCH 1/3] image for linux/arm64 --- .github/workflows/main.yml | 1 + Dockerfile | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c72545b..f1931df 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -47,6 +47,7 @@ jobs: - uses: docker/build-push-action@v2 with: push: true + platforms: linux/arm64 tags: docker.pkg.github.com/${{ github.repository }}/noolite:${{ github.sha }} latest: diff --git a/Dockerfile b/Dockerfile index 6968316..4cdf067 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,7 +8,7 @@ RUN zip -r -0 /zoneinfo.zip . FROM golang:1.16 AS builder WORKDIR /gomod/noolite ADD . . -RUN CGO_ENABLED=0 GOOS=linux GOARCH=arm go build -o /go/bin/noolite ./cmd +RUN CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -o /go/bin/noolite ./cmd FROM scratch # configurations From ec98d22c5e2dc7baeec07659a7b658c5be421746 Mon Sep 17 00:00:00 2001 From: dmnbars Date: Thu, 10 Jun 2021 00:00:12 +0300 Subject: [PATCH 2/3] using arm64v8/alpine --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 4cdf067..cf5657c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM alpine:latest as alpine +FROM arm64v8/alpine:latest as alpine RUN apk --no-cache add tzdata zip ca-certificates WORKDIR /usr/share/zoneinfo # -0 means no compression. Needed because go's From 592cbd2a6d816854b1a445b0dd8e7a7a6f34e865 Mon Sep 17 00:00:00 2001 From: dmnbars Date: Thu, 10 Jun 2021 10:34:13 +0300 Subject: [PATCH 3/3] new way to set arm64 --- Dockerfile | 6 ++-- ansible/playbooks/deploy.yml | 2 ++ ansible/playbooks/prepare.yml | 64 ----------------------------------- 3 files changed, 5 insertions(+), 67 deletions(-) delete mode 100644 ansible/playbooks/prepare.yml diff --git a/Dockerfile b/Dockerfile index cf5657c..fa359c8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,16 +1,16 @@ -FROM arm64v8/alpine:latest as alpine +FROM --platform=linux/arm64 alpine:latest as alpine RUN apk --no-cache add tzdata zip ca-certificates WORKDIR /usr/share/zoneinfo # -0 means no compression. Needed because go's # tz loader doesn't handle compressed data. RUN zip -r -0 /zoneinfo.zip . -FROM golang:1.16 AS builder +FROM --platform=linux/arm64 golang:1.16 AS builder WORKDIR /gomod/noolite ADD . . RUN CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -o /go/bin/noolite ./cmd -FROM scratch +FROM --platform=linux/arm64 scratch # configurations WORKDIR /app # the timezone data: diff --git a/ansible/playbooks/deploy.yml b/ansible/playbooks/deploy.yml index 87894d0..5a7d5a9 100644 --- a/ansible/playbooks/deploy.yml +++ b/ansible/playbooks/deploy.yml @@ -1,6 +1,7 @@ --- - name: deploy hosts: rasp + gather_facts: no tasks: - name: login github docker registry docker_login: @@ -15,6 +16,7 @@ state: started pull: yes restart_policy: always + restart: yes devices: - "/dev/ttyUSB0:/dev/ttyUSB0" env: diff --git a/ansible/playbooks/prepare.yml b/ansible/playbooks/prepare.yml deleted file mode 100644 index 6ebd4a1..0000000 --- a/ansible/playbooks/prepare.yml +++ /dev/null @@ -1,64 +0,0 @@ ---- -- name: prepare - hosts: rasp - tasks: - - name: upgrade packages - become: yes - apt: - update_cahe: yes - upgrade: yes - - - name: install deps - become: yes - apt: - name: "{{ item }}" - state: latest - loop: - - apt-transport-https - - ca-certificates - - curl - - software-properties-common - - - name: install GPG key - become: yes - apt_key: - url: "https://download.docker.com/linux/ubuntu/gpg" - state: present - - - name: add apt repository - become: yes - apt_repository: - repo: "deb [arch=amd64] https://download.docker.com/linux/ubuntu {{ ansible_lsb.codename }} stable" - state: present - - - name: install docker - become: yes - apt: - name: docker-ce - state: latest - update_cache: yes - - - name: docker permissions - block: - - set_fact: - user: "{{ ansible_env['USER'] }}" - - - name: ensure group "docker" exists - group: - name: docker - state: present - - - name: add currenct user to docker group - become: yes - user: - name: "{{ ansible_env['USER'] }}" - groups: docker - append: yes - - - name: fix docker permissions - become: yes - file: - path: "{{ ansible_env['HOME'] }}/.docker" - recurse: true - owner: "{{ ansible_env['USER'] }}" - group: docker