Skip to content

Commit

Permalink
Merge pull request #37 from lucor/docker-images-refactoring
Browse files Browse the repository at this point in the history
Docker images refactoring
  • Loading branch information
lucor committed Mar 31, 2021
2 parents 27fce2c + 7340a9e commit 578925f
Show file tree
Hide file tree
Showing 33 changed files with 637 additions and 159 deletions.
2 changes: 2 additions & 0 deletions .gitignore
@@ -1 +1,3 @@
/fyne-cross
/*.dmg
/*.xip
29 changes: 26 additions & 3 deletions CHANGELOG.md
@@ -1,11 +1,34 @@
# Changelog - Fyne.io fyne-cross

## Unreleased
## [1.1.0] Unreleased

### Added

- Add FreeBSD on arm64 target #29
- Add the `darwin-image` command to build the darwin docker image
- Add the `local` flag for darwin to build directly from the host
- Add a dedicated docker image for macOS
- Add a dedicated docker image for Windows

### Changed

- Update Go to v1.16.2
- Update fyne CLI to v2.0.1
- Update FreeBSD SDK to v12.2 #29
- Refactor docker images layout to ensure compatibility with previous versions of fyne-cross

### Fixed

- Fix android keystore path is not resolved correctly
- Fix some release flags are always set even if empty
- Fix appID flag should not have a default #25

## [1.0.0]
### Removed

- Remove darwin 386 target
- Remove the dependency from the docker/golang-cross image for the base image

## 1.0.0 - 13 December 2020
- Add support for "fyne release" #3
- Add support for creating packaged .tar.gz bundles on freebsd #6
- Add support for Linux Wayland #10
Expand All @@ -15,7 +38,7 @@
- Fix build failure for Linux mobile #19
- Update Go to v1.14.13

## [0.9.0]
## 0.9.0 - 17 October 2020
- Releaseing under project namespace with previous 2.2.1 becoming 0.9.0 in fyne-io namespace


Expand Down
109 changes: 81 additions & 28 deletions Makefile
@@ -1,30 +1,83 @@
tag := $(shell date +"%y.%m.%d")

build-images:
@docker build -f ${CURDIR}/docker/base/Dockerfile -t fyneio/fyne-cross:base-latest .
@docker tag fyneio/fyne-cross:base-latest fyneio/fyne-cross:base-$(tag)
@docker build -f ${CURDIR}/docker/linux-386/Dockerfile -t fyneio/fyne-cross:linux-386-latest .
@docker tag fyneio/fyne-cross:linux-386-latest fyneio/fyne-cross:linux-386-$(tag)
@docker build -f ${CURDIR}/docker/linux-arm/Dockerfile -t fyneio/fyne-cross:linux-arm-latest .
@docker tag fyneio/fyne-cross:linux-arm-latest fyneio/fyne-cross:linux-arm-$(tag)
@docker build -f ${CURDIR}/docker/linux-arm64/Dockerfile -t fyneio/fyne-cross:linux-arm64-latest .
@docker tag fyneio/fyne-cross:linux-arm64-latest fyneio/fyne-cross:linux-arm64-$(tag)
@docker build -f ${CURDIR}/docker/android/Dockerfile -t fyneio/fyne-cross:android-latest .
@docker tag fyneio/fyne-cross:android-latest fyneio/fyne-cross:android-$(tag)
@docker build -f ${CURDIR}/docker/freebsd/Dockerfile -t fyneio/fyne-cross:freebsd-latest .
@docker tag fyneio/fyne-cross:freebsd-latest fyneio/fyne-cross:freebsd-$(tag)

push-images:
$(eval TAG := $(date +"%y.%m.%d"))
@docker push fyneio/fyne-cross:base-latest
@docker push fyneio/fyne-cross:base-$(tag)
@docker push fyneio/fyne-cross:linux-386-latest
@docker push fyneio/fyne-cross:linux-386-$(tag)
@docker push fyneio/fyne-cross:linux-arm-latest
@docker push fyneio/fyne-cross:linux-arm-$(tag)
@docker push fyneio/fyne-cross:linux-arm64-latest
@docker push fyneio/fyne-cross:linux-arm64-$(tag)
@docker push fyneio/fyne-cross:android-latest
@docker push fyneio/fyne-cross:android-$(tag)
@docker push fyneio/fyne-cross:freebsd-latest
@docker push fyneio/fyne-cross:freebsd-$(tag)
FYNE_CROSS_VERSION := "1.1"

base:
@docker build -f ${CURDIR}/docker/base/Dockerfile -t fyneio/fyne-cross:${FYNE_CROSS_VERSION}-base .

base-llvm: base
@docker build --build-arg FYNE_CROSS_VERSION=${FYNE_CROSS_VERSION} -f ${CURDIR}/docker/base-llvm/Dockerfile -t fyneio/fyne-cross:${FYNE_CROSS_VERSION}-base-llvm .

android: base
@docker build --build-arg FYNE_CROSS_VERSION=${FYNE_CROSS_VERSION} -f ${CURDIR}/docker/android/Dockerfile -t fyneio/fyne-cross:${FYNE_CROSS_VERSION}-android .

darwin: base-llvm
@docker build --build-arg FYNE_CROSS_VERSION=${FYNE_CROSS_VERSION} -f ${CURDIR}/docker/darwin/Dockerfile -t fyneio/fyne-cross:${FYNE_CROSS_VERSION}-darwin .

base-freebsd: base-llvm
@docker build --build-arg FYNE_CROSS_VERSION=${FYNE_CROSS_VERSION} -f ${CURDIR}/docker/base-freebsd/Dockerfile -t fyneio/fyne-cross:${FYNE_CROSS_VERSION}-base-freebsd .

freebsd: base-freebsd
@docker build --build-arg FYNE_CROSS_VERSION=${FYNE_CROSS_VERSION} -f ${CURDIR}/docker/freebsd-amd64/Dockerfile -t fyneio/fyne-cross:${FYNE_CROSS_VERSION}-freebsd-amd64 .
@docker build --build-arg FYNE_CROSS_VERSION=${FYNE_CROSS_VERSION} -f ${CURDIR}/docker/freebsd-arm64/Dockerfile -t fyneio/fyne-cross:${FYNE_CROSS_VERSION}-freebsd-arm64 .

linux: base
@docker build --build-arg FYNE_CROSS_VERSION=${FYNE_CROSS_VERSION} -f ${CURDIR}/docker/linux-386/Dockerfile -t fyneio/fyne-cross:${FYNE_CROSS_VERSION}-linux-386 .
@docker build --build-arg FYNE_CROSS_VERSION=${FYNE_CROSS_VERSION} -f ${CURDIR}/docker/linux-arm/Dockerfile -t fyneio/fyne-cross:${FYNE_CROSS_VERSION}-linux-arm .
@docker build --build-arg FYNE_CROSS_VERSION=${FYNE_CROSS_VERSION} -f ${CURDIR}/docker/linux-arm64/Dockerfile -t fyneio/fyne-cross:${FYNE_CROSS_VERSION}-linux-arm64 .

windows: base
@docker build --build-arg FYNE_CROSS_VERSION=${FYNE_CROSS_VERSION} -f ${CURDIR}/docker/windows/Dockerfile -t fyneio/fyne-cross:${FYNE_CROSS_VERSION}-windows .

# build all images for release. Note do not build darwin
build-images: base android freebsd linux windows

# tag the images with the YY.MM.DD suffix
tag-images:
# tag base images
@docker tag fyneio/fyne-cross:${FYNE_CROSS_VERSION}-base fyneio/fyne-cross:${FYNE_CROSS_VERSION}-base-$(tag)
@docker tag fyneio/fyne-cross:${FYNE_CROSS_VERSION}-base-llvm fyneio/fyne-cross:${FYNE_CROSS_VERSION}-base-llmv-$(tag)
@docker tag fyneio/fyne-cross:${FYNE_CROSS_VERSION}-base-freebsd fyneio/fyne-cross:${FYNE_CROSS_VERSION}-base-freebsd-$(tag)
# tag android images
@docker tag fyneio/fyne-cross:${FYNE_CROSS_VERSION}-android fyneio/fyne-cross:${FYNE_CROSS_VERSION}-android-$(tag)
# tag linux images
@docker tag fyneio/fyne-cross:${FYNE_CROSS_VERSION}-linux-386 fyneio/fyne-cross:${FYNE_CROSS_VERSION}-linux-386-$(tag)
@docker tag fyneio/fyne-cross:${FYNE_CROSS_VERSION}-linux-arm fyneio/fyne-cross:${FYNE_CROSS_VERSION}-linux-arm-$(tag)
@docker tag fyneio/fyne-cross:${FYNE_CROSS_VERSION}-linux-arm64 fyneio/fyne-cross:${FYNE_CROSS_VERSION}-linux-arm64-$(tag)
# tag freebsd images
@docker tag fyneio/fyne-cross:${FYNE_CROSS_VERSION}-freebsd fyneio/fyne-cross:${FYNE_CROSS_VERSION}-freebsd-amd64-$(tag)
@docker tag fyneio/fyne-cross:${FYNE_CROSS_VERSION}-freebsd fyneio/fyne-cross:${FYNE_CROSS_VERSION}-freebsd-arm64-$(tag)
# tag windows images
@docker tag fyneio/fyne-cross:${FYNE_CROSS_VERSION}-windows fyneio/fyne-cross:${FYNE_CROSS_VERSION}-windows-$(tag)

# push the latest images
push-latest-images:
@docker push fyneio/fyne-cross:${FYNE_CROSS_VERSION}-base
@docker push fyneio/fyne-cross:${FYNE_CROSS_VERSION}-base-llvm
@docker push fyneio/fyne-cross:${FYNE_CROSS_VERSION}-base-freebsd
@docker push fyneio/fyne-cross:${FYNE_CROSS_VERSION}-android
@docker push fyneio/fyne-cross:${FYNE_CROSS_VERSION}-linux-386
@docker push fyneio/fyne-cross:${FYNE_CROSS_VERSION}-linux-arm
@docker push fyneio/fyne-cross:${FYNE_CROSS_VERSION}-linux-arm64
@docker push fyneio/fyne-cross:${FYNE_CROSS_VERSION}-freebsd-amd64
@docker push fyneio/fyne-cross:${FYNE_CROSS_VERSION}-freebsd-arm64
@docker push fyneio/fyne-cross:${FYNE_CROSS_VERSION}-windows

# push the tagged images
push-tag-images:
@docker push fyneio/fyne-cross:${FYNE_CROSS_VERSION}-base-$(tag)
@docker push fyneio/fyne-cross:${FYNE_CROSS_VERSION}-base-llvm-$(tag)
@docker push fyneio/fyne-cross:${FYNE_CROSS_VERSION}-base-freebsd-$(tag)
@docker push fyneio/fyne-cross:${FYNE_CROSS_VERSION}-android-$(tag)
@docker push fyneio/fyne-cross:${FYNE_CROSS_VERSION}-linux-386-$(tag)
@docker push fyneio/fyne-cross:${FYNE_CROSS_VERSION}-linux-arm-$(tag)
@docker push fyneio/fyne-cross:${FYNE_CROSS_VERSION}-linux-arm64-$(tag)
@docker push fyneio/fyne-cross:${FYNE_CROSS_VERSION}-freebsd-amd64-$(tag)
@docker push fyneio/fyne-cross:${FYNE_CROSS_VERSION}-freebsd-arm64-$(tag)
@docker push fyneio/fyne-cross:${FYNE_CROSS_VERSION}-windows-$(tag)

# push all images: latest and tagged
push-images: push-latest-images push-tag-images

embed:
go run internal/cmd/embed/main.go
35 changes: 27 additions & 8 deletions README.md
Expand Up @@ -2,13 +2,13 @@

[![CI](https://github.com/fyne-io/fyne-cross/workflows/CI/badge.svg)](https://github.com/fyne-io/fyne-cross/actions?query=workflow%3ACI) [![Go Report Card](https://goreportcard.com/badge/github.com/fyne-io/fyne-cross)](https://goreportcard.com/report/github.com/fyne-io/fyne-cross) [![GoDoc](https://godoc.org/github.com/fyne-io/fyne-cross?status.svg)](http://godoc.org/github.com/fyne-io/fyne-cross) [![version](https://img.shields.io/github/v/tag/fyne-io/fyne-cross?label=version)]()

fyne-cross is a simple tool to cross compile and create distribution packages for [Fyne](https://fyne.io) applications.

It has been inspired by [xgo](https://github.com/karalabe/xgo) and uses a [docker image](https://hub.docker.com/r/fyneio/fyne-cross) built on top of the [golang-cross](https://github.com/docker/golang-cross) image, that includes the MinGW compiler for windows, and an OSX SDK, along with the Fyne requirements.
fyne-cross is a simple tool to cross compile and create distribution packages
for [Fyne](https://fyne.io) applications using docker images that include Linux,
the MinGW compiler for Windows, FreeBSD, and a macOS SDK, along with the Fyne
requirements.

Supported targets are:
- darwin/amd64
- darwin/386
- freebsd/amd64
- linux/amd64
- linux/386
Expand All @@ -20,6 +20,7 @@ Supported targets are:
- ios

> Note:
> - starting from v1.1.0 the image with the OSX SDK is no more available via docker hub and has to be build manually, see the [Build the darwin image](#build_darwin_image) section below.
> - iOS compilation is supported only on darwin hosts. See [fyne pre-requisites](https://developer.fyne.io/started/#prerequisites) for details.
> - macOS packaging for public distrubution (release mode) is supported only on darwin hosts.
> - windows packaging for public distrubution (release mode) is supported only on windows hosts.
Expand Down Expand Up @@ -109,6 +110,24 @@ fyne-cross linux
fyne-cross linux -output bugs ./cmd/bugs
```

## <a name="build_darwin_image"></a>Build the docker image for OSX/Darwin/Apple builds
The docker image for darwin is not provided via docker hub and need to build manually since it depends on the OSX SDK.

**[Please ensure you have read and understood the Xcode license
terms before continuing.](https://www.apple.com/legal/sla/docs/xcode.pdf)**

To build the image:
1. [Download Command Line Tools for Xcode](https://developer.apple.com/download/more) >= 12.4
2. Run: `fyne-cross darwin-image --xcode-path /path/to/Command_Line_Tools_for_Xcode_<version>.dmg`

The command above will:
- install the dependencies required by [osxcross](https://github.com/tpoechtrager/osxcross) to package the macOS SDK and compile the macOS cross toolchain.
- package the macOS SDK
- compile the macOS cross toolchain
- build the `fyneio/fyne-cross:<ver>-darwin` image that will be used by fyne-cross

> NOTE: the creation of the image may take several minutes and may require more than 25 GB of free disk space.
## Contribute

- Fork and clone the repository
Expand All @@ -119,8 +138,8 @@ fyne-cross linux -output bugs ./cmd/bugs

See [contributors](https://github.com/fyne-io/fyne-cross/graphs/contributors) page

## Legal note
## Credits

OSX/Darwin/Apple builds:
**[Please ensure you have read and understood the Xcode license
terms before continuing.](https://www.apple.com/legal/sla/docs/xcode.pdf)**
- [osxcross](https://github.com/tpoechtrager/osxcross) for the macOS Cross toolchain for Linux
- [golang-cross](https://github.com/docker/golang-cross) for the inspiration and the docker images used in the initial versions
- [xgo](https://github.com/karalabe/xgo) for the inspiration
53 changes: 44 additions & 9 deletions docker/CHANGELOG.md
Expand Up @@ -2,31 +2,66 @@

All notable changes to the fyne-cross docker images will be documented in this file.

Release cycle won't follow the fyne-cross one, so the images will be tagged using the label
year.month.day along with the latest one.
## fyne 1.1.x compatible

# Release 20.12.13
Latest versions available on Docker Hub are:

- fyneio/fyne-cross:1.1-base
- fyneio/fyne-cross:1.1-base-llvm
- fyneio/fyne-cross:1.1-base-freebsd
- fyneio/fyne-cross:1.1-android
- fyneio/fyne-cross:1.1-freebsd-amd64
- fyneio/fyne-cross:1.1-freebsd-arm64
- fyneio/fyne-cross:1.1-linux-386
- fyneio/fyne-cross:1.1-linux-arm64
- fyneio/fyne-cross:1.1-linux-arm
- fyneio/fyne-cross:1.1-windows

Release cycle won't follow the fyne-cross one, so the images will be tagged and
available on Docker Hub using the label year.month.day along with the tags
above.

Example: `fyneio/fyne-cross:1.1-base-21.03.17`

## fyne 1.0.x compatible

Latest versions available on Docker Hub are:
- fyneio/fyne-cross:base-latest
- fyneio/fyne-cross:darwin-latest
- fyneio/fyne-cross:linux-386-latest
- fyneio/fyne-cross:linux-arm64-latest
- fyneio/fyne-cross:linux-arm-latest
- fyneio/fyne-cross:android-latest
- fyneio/fyne-cross:freebsd-latest

Release cycle won't follow the fyne-cross one, so the images will be tagged and
available on Docker Hub using the label year.month.day along with the tags
above.

Example: `fyneio/fyne-cross:base-20.12.13`

### Release 20.12.13
- Update Go to v1.14.13
- Fix build failure for Linux mobile #19

# Release 20.12.10
### Release 20.12.10
- Update fyne cli to v1.4.2
> Note: this version is the last that provides Go v1.13.x
# Release 20.12.05
### Release 20.12.05
- Update fyne cli to v1.4.2-0.20201204171445-8f33697cf611
- Add support for Linux Wayland #10

# Release 20.11.28
### Release 20.11.28
- Update fyne cli to v1.4.2-0.20201127180716-f9f91c194737 fyne-io#1609

# Release 20.11.25
### Release 20.11.25
- Update fyne cli to v1.4.2-0.20201125075943-97ad77d2abe0 fyne-io#1538

# Release 20.11.23
### Release 20.11.23
- Update fyne cli to v1.4.2-0.20201122132119-67b762f56dc0 fyne-io#1527

# Release 20.11.04
### Release 20.11.04
- fyne cli updated to v1.4.0

# Archive
Expand Down
21 changes: 15 additions & 6 deletions docker/README.md
Expand Up @@ -4,9 +4,18 @@ This folder contains the docker images used by fyne-cross to build the Fyne appl

It provides the following images:

- fyneio/fyne-cross:base
- fyneio/fyne-cross:linux-386
- fyneio/fyne-cross:linux-arm64
- fyneio/fyne-cross:linux-arm
- fyneio/fyne-cross:android
- fyneio/fyne-cross:freebsd
- fyneio/fyne-cross:1.1-base
- fyneio/fyne-cross:1.1-base-llvm
- fyneio/fyne-cross:1.1-base-freebsd
- fyneio/fyne-cross:1.1-android
- fyneio/fyne-cross:1.1-darwin
- fyneio/fyne-cross:1.1-freebsd-amd64
- fyneio/fyne-cross:1.1-freebsd-arm64
- fyneio/fyne-cross:1.1-linux-386
- fyneio/fyne-cross:1.1-linux-arm64
- fyneio/fyne-cross:1.1-linux-arm
- fyneio/fyne-cross:1.1-windows

> Note:
> - images are compatible with fyne-cross 1.1.x
> - the darwin image is not hosted on dockerhub
3 changes: 2 additions & 1 deletion docker/android/Dockerfile
@@ -1,4 +1,5 @@
FROM fyneio/fyne-cross:base-latest
ARG FYNE_CROSS_VERSION
FROM fyneio/fyne-cross:${FYNE_CROSS_VERSION}-base

ENV JAVA_HOME /usr/local/android_jdk8
ENV ANDROID_HOME /usr/local/android_sdk
Expand Down
45 changes: 45 additions & 0 deletions docker/base-freebsd/Dockerfile
@@ -0,0 +1,45 @@
ARG FYNE_CROSS_VERSION
FROM fyneio/fyne-cross:${FYNE_CROSS_VERSION}-base-llvm as pkg

# Build pkg for linux
# Based on https://github.com/freebsd/pkg/blob/release-1.12/.cirrus.yml#L19-L29
RUN apt-get update -qq \
&& apt-get install -y -q --no-install-recommends \
libsqlite3-dev \
libbsd-dev \
libarchive-dev \
libssl-dev \
liblzma-dev \
liblua5.2-dev \
nettle-dev \
liblzo2-dev \
libattr1-dev \
libacl1-dev \
build-essential \
zlib1g-dev \
libbz2-dev \
m4 \
libexpat1-dev \
liblz4-dev \
libxml2-dev \
libzstd-dev \
bsdtar \
&& apt-get -qy autoremove \
&& apt-get clean \
&& rm -r /var/lib/apt/lists/*;

RUN mkdir -p /pkg-src \
&& mkdir -p /pkg/etc \
&& curl -L https://github.com/freebsd/pkg/archive/1.12.0.tar.gz | bsdtar -xf - -C /pkg-src \
&& cd /pkg-src/pkg-* \
&& ./scripts/install_deps.sh \
&& ./configure --with-libarchive.pc --prefix=/pkg \
&& make -j4 || make V=1 \
&& make install \
&& rm -rf /pkg-src

FROM pkg as base-freebsd

COPY --from=pkg /pkg /pkg

ENV PATH=/pkg/sbin:${PATH}
18 changes: 18 additions & 0 deletions docker/base-llvm/Dockerfile
@@ -0,0 +1,18 @@
ARG LLVM_VERSION=12
ARG FYNE_CROSS_VERSION

FROM fyneio/fyne-cross:${FYNE_CROSS_VERSION}-base
ARG LLVM_VERSION

RUN wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add - \
&& echo "deb http://apt.llvm.org/buster/ llvm-toolchain-buster-${LLVM_VERSION} main" | tee /etc/apt/sources.list.d/llvm.list > /dev/null \
&& apt-get update -qq \
&& apt-get install -y -q --no-install-recommends \
clang-${LLVM_VERSION} \
llvm-${LLVM_VERSION} \
lld-${LLVM_VERSION} \
&& apt-get -qy autoremove \
&& apt-get clean \
&& rm -r /var/lib/apt/lists/*;

ENV PATH=/usr/lib/llvm-${LLVM_VERSION}/bin:${PATH}

0 comments on commit 578925f

Please sign in to comment.