Skip to content

Commit

Permalink
Docker: switch from seihon to buildx (evcc-io#4178)
Browse files Browse the repository at this point in the history
  • Loading branch information
andig authored Aug 21, 2022
1 parent dd8c8e4 commit bea6544
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 166 deletions.
17 changes: 11 additions & 6 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,21 +41,26 @@ jobs:
- name: Checkout
uses: actions/checkout@v3
with:
ref: refs/heads/master # force master
fetch-depth: 0

- name: Install
env:
SEIHON_VERSION: v0.9.0
run: curl -sfL https://raw.githubusercontent.com/ldez/seihon/master/godownloader.sh | sudo bash -s -- -b $GOPATH/bin ${SEIHON_VERSION}

- name: Login
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASS }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Publish
run: make publish-nightly
uses: docker/build-push-action@v3
with:
context: .
platforms: linux/amd64,linux/arm64,linux/arm/v6
push: true
tags: |
andig/evcc:nightly
apt:
name: Publish APT nightly
Expand Down
16 changes: 10 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,23 @@ jobs:
ref: refs/heads/master # force master
fetch-depth: 0

- name: Install
env:
SEIHON_VERSION: v0.9.0
run: curl -sfL https://raw.githubusercontent.com/ldez/seihon/master/godownloader.sh | sudo bash -s -- -b $GOPATH/bin ${SEIHON_VERSION}

- name: Login
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASS }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Publish
run: make publish-release
uses: docker/build-push-action@v3
with:
context: .
platforms: linux/amd64,linux/arm64,linux/arm/v6
push: true
tags: |
andig/evcc:latest
apt:
name: Publish Github & APT release
Expand Down
23 changes: 17 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# STEP 1 build ui
FROM node:16-alpine as node
FROM --platform=$BUILDPLATFORM node:16-alpine as node

RUN apk update && apk add --no-cache make alpine-sdk python3

WORKDIR /build

# install node tools
COPY Makefile .
COPY package*.json ./
RUN make install-ui
RUN npm ci

# build ui
COPY Makefile .
COPY assets assets
COPY vite.config.js vite.config.js
COPY .eslintrc.js .eslintrc.js
Expand All @@ -20,15 +20,15 @@ RUN make clean ui


# STEP 2 build executable binary
FROM golang:1.18-alpine as builder
FROM --platform=$BUILDPLATFORM golang:1.18-alpine as builder

# Install git + SSL ca certificates.
# Git is required for fetching the dependencies.
# Ca-certificates is required to call HTTPS endpoints.
RUN apk update && apk add --no-cache git ca-certificates tzdata alpine-sdk && update-ca-certificates

# define RELEASE=1 to hide commit hash
ARG RELEASE={{ env "RELEASE" }}
ARG RELEASE=0

WORKDIR /build

Expand All @@ -48,7 +48,18 @@ RUN make assets
COPY --from=node /build/dist /build/dist

# build
RUN RELEASE=${RELEASE} make build
ARG TARGETOS
ARG TARGETARCH
ARG TARGETVARIANT

RUN case "${TARGETVARIANT}" in \
"armhf") export GOARM='6' ;; \
"armv7") export GOARM='6' ;; \
"v6") export GOARM='6' ;; \
"v7") export GOARM='7' ;; \
esac;

RUN RELEASE=${RELEASE} GOOS=${TARGETOS} GOARCH=${TARGETARCH} make build


# STEP 3 build a small image including module support
Expand Down
19 changes: 5 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.PHONY: default all clean install install-ui ui assets docs lint test-ui lint-ui test build test-release release
.PHONY: docker publish-testing publish-latest publish-nightly publish-release
.PHONY: docker publish-testing publish-nightly publish-release
.PHONY: prepare-image image-rootfs image-update
.PHONY: soc

Expand All @@ -19,8 +19,7 @@ BUILD_ARGS := -ldflags='$(LD_FLAGS)'

# docker
DOCKER_IMAGE := andig/evcc
ALPINE_VERSION := 3.15
TARGETS := arm.v6,arm.v8,amd64
PLATFORM := linux/amd64,linux/arm64,linux/arm/v6

# gokrazy image
IMAGE_FILE := evcc_$(TAG_NAME).image
Expand Down Expand Up @@ -81,23 +80,15 @@ docker:

publish-testing:
@echo Version: $(VERSION) $(SHA) $(BUILD_DATE)
seihon publish --dry-run=false --template docker/tmpl.Dockerfile --base-runtime-image alpine:$(ALPINE_VERSION) \
--image-name $(DOCKER_IMAGE) -v "testing" --targets=$(TARGETS)

publish-latest:
@echo Version: $(VERSION) $(SHA) $(BUILD_DATE)
seihon publish --dry-run=false --template docker/tmpl.Dockerfile --base-runtime-image alpine:$(ALPINE_VERSION) \
--image-name $(DOCKER_IMAGE) -v "latest" --targets=$(TARGETS)
docker buildx build --platform $(PLATFORM) --tag $(DOCKER_IMAGE):testing --push .

publish-nightly:
@echo Version: $(VERSION) $(SHA) $(BUILD_DATE)
seihon publish --dry-run=false --template docker/ci.Dockerfile --base-runtime-image alpine:$(ALPINE_VERSION) \
--image-name $(DOCKER_IMAGE) -v "nightly" --targets=$(TARGETS)
docker buildx build --platform $(PLATFORM) --tag $(DOCKER_IMAGE):nightly .

publish-release:
@echo Version: $(VERSION) $(SHA) $(BUILD_DATE)
RELEASE=1 seihon publish --dry-run=false --template docker/ci.Dockerfile --base-runtime-image alpine:$(ALPINE_VERSION) \
--image-name $(DOCKER_IMAGE) -v "latest" -v "$(TAG_NAME)" --targets=$(TARGETS)
docker buildx build --build-arg RELEASE=1 --platform $(PLATFORM) --tag $(DOCKER_IMAGE):latest .

apt-nightly:
$(foreach file, $(wildcard $(PACKAGES)/*.deb), \
Expand Down
55 changes: 0 additions & 55 deletions docker/ci.Dockerfile

This file was deleted.

79 changes: 0 additions & 79 deletions docker/tmpl.Dockerfile

This file was deleted.

0 comments on commit bea6544

Please sign in to comment.