build: create amd64/arm64 compatible docker images (#23)
This commit is contained in:
109
.github/workflows/build.yml
vendored
109
.github/workflows/build.yml
vendored
@@ -12,10 +12,16 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
# dependencies
|
# dependencies
|
||||||
- name: dependencies
|
- name: goreleaser
|
||||||
run: |
|
run: |
|
||||||
curl -sfL https://install.goreleaser.com/github.com/goreleaser/goreleaser.sh | sudo sh -s -- -b /usr/local/bin
|
curl -sfL https://install.goreleaser.com/github.com/goreleaser/goreleaser.sh | sudo sh -s -- -b /usr/local/bin
|
||||||
|
|
||||||
|
- name: qemu
|
||||||
|
uses: docker/setup-qemu-action@v1
|
||||||
|
|
||||||
|
- name: buildx
|
||||||
|
uses: docker/setup-buildx-action@v1
|
||||||
|
|
||||||
# checkout
|
# checkout
|
||||||
- name: checkout
|
- name: checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
@@ -27,8 +33,11 @@ jobs:
|
|||||||
uses: actions/setup-go@v1
|
uses: actions/setup-go@v1
|
||||||
with:
|
with:
|
||||||
go-version: 1.16
|
go-version: 1.16
|
||||||
- run: go version
|
|
||||||
- run: go env
|
- name: go info
|
||||||
|
run: |
|
||||||
|
go version
|
||||||
|
go env
|
||||||
|
|
||||||
# cache
|
# cache
|
||||||
- name: cache
|
- name: cache
|
||||||
@@ -50,7 +59,8 @@ jobs:
|
|||||||
make test
|
make test
|
||||||
|
|
||||||
# git status
|
# git status
|
||||||
- run: git status
|
- name: git status
|
||||||
|
run: git status
|
||||||
|
|
||||||
# build
|
# build
|
||||||
- name: build
|
- name: build
|
||||||
@@ -86,43 +96,64 @@ jobs:
|
|||||||
name: build_windows
|
name: build_windows
|
||||||
path: dist/*windows*
|
path: dist/*windows*
|
||||||
|
|
||||||
# docker build (latest & tag)
|
# docker login
|
||||||
- name: docker - build latest
|
- name: docker login
|
||||||
if: startsWith(github.ref, 'refs/tags/') == true
|
env:
|
||||||
uses: docker/build-push-action@v1
|
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
|
||||||
with:
|
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
|
||||||
username: ${{ secrets.DOCKER_USERNAME }}
|
run: |
|
||||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
echo "${DOCKER_PASSWORD}" | docker login --username "${DOCKER_USERNAME}" --password-stdin
|
||||||
repository: cloudb0x/nabarr
|
|
||||||
dockerfile: docker/Dockerfile
|
|
||||||
tags: latest
|
|
||||||
tag_with_ref: true
|
|
||||||
tag_with_sha: false
|
|
||||||
always_pull: true
|
|
||||||
|
|
||||||
# docker build (master)
|
# docker build (latest & tag)
|
||||||
- name: docker - build master
|
- name: release tag
|
||||||
if: github.ref == 'refs/heads/master'
|
if: startsWith(github.ref, 'refs/tags/') == true
|
||||||
uses: docker/build-push-action@v1
|
uses: little-core-labs/get-git-tag@v3.0.2
|
||||||
|
id: releasetag
|
||||||
with:
|
with:
|
||||||
username: ${{ secrets.DOCKER_USERNAME }}
|
tagRegex: "v?(.+)"
|
||||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
|
||||||
repository: cloudb0x/nabarr
|
- name: docker - build release
|
||||||
dockerfile: docker/Dockerfile
|
if: startsWith(github.ref, 'refs/tags/') == true
|
||||||
tags: master
|
uses: docker/build-push-action@v2
|
||||||
tag_with_ref: false
|
with:
|
||||||
tag_with_sha: false
|
context: .
|
||||||
always_pull: true
|
file: ./docker/Dockerfile
|
||||||
|
platforms: linux/amd64,linux/arm64
|
||||||
|
pull: true
|
||||||
|
push: true
|
||||||
|
tags: |
|
||||||
|
cloudb0x/nabarr:${{ steps.releasetag.outputs.tag }}
|
||||||
|
cloudb0x/nabarr:latest
|
||||||
|
|
||||||
# docker build (branch)
|
# docker build (branch)
|
||||||
- name: docker - build other
|
- name: branch name
|
||||||
if: startsWith(github.ref, 'refs/heads/master') == false
|
if: startsWith(github.ref, 'refs/tags/') == false
|
||||||
uses: docker/build-push-action@v1
|
id: branch-name
|
||||||
|
uses: tj-actions/branch-names@v2.2
|
||||||
|
|
||||||
|
- name: docker tag
|
||||||
|
if: startsWith(github.ref, 'refs/tags/') == false
|
||||||
|
uses: frabert/replace-string-action@master
|
||||||
|
id: dockertag
|
||||||
with:
|
with:
|
||||||
username: ${{ secrets.DOCKER_USERNAME }}
|
pattern: '[:\.\/]+'
|
||||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
string: "${{ steps.branch-name.outputs.current_branch }}"
|
||||||
repository: cloudb0x/nabarr
|
replace-with: '-'
|
||||||
dockerfile: docker/Dockerfile
|
flags: 'g'
|
||||||
tag_with_ref: true
|
|
||||||
tag_with_sha: false
|
- name: docker - build branch
|
||||||
always_pull: true
|
if: startsWith(github.ref, 'refs/tags/') == false
|
||||||
|
uses: docker/build-push-action@v2
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
file: ./docker/Dockerfile
|
||||||
|
platforms: linux/amd64,linux/arm64
|
||||||
|
pull: true
|
||||||
|
push: true
|
||||||
|
tags: |
|
||||||
|
cloudb0x/nabarr:${{ steps.dockertag.outputs.replaced }}
|
||||||
|
|
||||||
|
# cleanup
|
||||||
|
- name: cleanup
|
||||||
|
run: |
|
||||||
|
rm -f ${HOME}/.docker/config.json
|
||||||
4
.github/workflows/cleanup.yml
vendored
4
.github/workflows/cleanup.yml
vendored
@@ -7,7 +7,7 @@ jobs:
|
|||||||
if: startsWith(github.event.ref_type, 'branch') == true
|
if: startsWith(github.event.ref_type, 'branch') == true
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Sanitize branch docker tag
|
- name: docker tag
|
||||||
uses: frabert/replace-string-action@master
|
uses: frabert/replace-string-action@master
|
||||||
id: dockertag
|
id: dockertag
|
||||||
with:
|
with:
|
||||||
@@ -16,7 +16,7 @@ jobs:
|
|||||||
replace-with: '-'
|
replace-with: '-'
|
||||||
flags: 'g'
|
flags: 'g'
|
||||||
|
|
||||||
- name: Remove branch docker tag
|
- name: remove docker tag
|
||||||
shell: bash
|
shell: bash
|
||||||
env:
|
env:
|
||||||
username: ${{ secrets.DOCKER_USERNAME }}
|
username: ${{ secrets.DOCKER_USERNAME }}
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
FROM sc4h/alpine-s6overlay:3.12
|
FROM sc4h/alpine-s6overlay:3.12
|
||||||
|
|
||||||
|
ARG TARGETOS
|
||||||
|
ARG TARGETARCH
|
||||||
|
|
||||||
ENV \
|
ENV \
|
||||||
PATH="/app/nabarr:${PATH}" \
|
PATH="/app/nabarr:${PATH}" \
|
||||||
APP_CONFIG="/config/config.yml" \
|
APP_CONFIG="/config/config.yml" \
|
||||||
@@ -8,7 +11,7 @@ ENV \
|
|||||||
APP_VERBOSITY="0"
|
APP_VERBOSITY="0"
|
||||||
|
|
||||||
# Binary
|
# Binary
|
||||||
COPY ["dist/nabarr_linux_amd64/nabarr", "/app/nabarr/nabarr"]
|
COPY ["dist/nabarr_${TARGETOS}_${TARGETARCH}/nabarr", "/app/nabarr/nabarr"]
|
||||||
|
|
||||||
# Add root files
|
# Add root files
|
||||||
COPY ["docker/run", "/etc/services.d/nabarr/run"]
|
COPY ["docker/run", "/etc/services.d/nabarr/run"]
|
||||||
|
|||||||
Reference in New Issue
Block a user