Skip to content

Commit

Permalink
docker CI script
Browse files Browse the repository at this point in the history
  • Loading branch information
hhanh00 committed Aug 22, 2021
1 parent 1d146a2 commit 425f43a
Show file tree
Hide file tree
Showing 19 changed files with 179 additions and 55 deletions.
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
build/**
**/target/**
46 changes: 46 additions & 0 deletions .github/workflows/builder.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# This is a basic workflow to help you get started with Actions

name: CI Build Image to Docker Hub

# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the main branch
push:
branches: [ docker ]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2

- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}

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

- name: Build and push
id: docker_build
uses: docker/build-push-action@v2
with:
context: ./
file: ./docker/Dockerfile-builder
push: true
tags: ${{ secrets.DOCKER_HUB_USERNAME }}/zwallet_builder:latest

- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
55 changes: 55 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# This is a basic workflow to help you get started with Actions

name: CI

# Controls when the workflow will run
on:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
with:
submodules: recursive

- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}

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

- name: Build and push
id: docker_build
uses: docker/build-push-action@v2
with:
context: ./
file: docker/Dockerfile
push: true
tags: ${{ secrets.DOCKER_HUB_USERNAME }}/zwallet:latest
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
secrets: "pwd=${{ secrets.JKS_PASSWD }}"

- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
39 changes: 0 additions & 39 deletions Dockerfile

This file was deleted.

10 changes: 6 additions & 4 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ if (flutterVersionName == null) {
flutterVersionName = '1.0'
}

def key = System.getenv("JKS_PASSWORD") ?: file("/run/secrets/pwd").text.trim()

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
Expand All @@ -49,10 +51,10 @@ android {

signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
storePassword keystoreProperties['storePassword']
keyAlias "zwallet"
keyPassword key
storeFile = rootProject.file("../docker/zwallet.jks")
storePassword key
}
}
buildTypes {
Expand Down
4 changes: 4 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export FEATURE=$1

cargo make --env COIN=$FEATURE --profile release
flutter build appbundle
2 changes: 0 additions & 2 deletions configure-and-build.sh → configure.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,3 @@ flutter pub run change_app_package_name:main me.hanh.$APP_NAME
flutter pub run flutter_launcher_icons:main
flutter pub run flutter_launcher_name:main
flutter pub run build_runner build
cargo make --env COIN=$FEATURE --profile release
flutter build apk --split-per-abi
14 changes: 14 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#syntax=docker/dockerfile:1.2
FROM hhanh00/zwallet_builder AS builder

ENV ANDROID_SDK_ROOT /Android/sdk
ENV PATH $PATH:$ANDROID_SDK_ROOT/platform-tools:/flutter/bin
ENV ANDROID_NDK_HOME /Android/android-ndk-r21e

COPY . /zwallet

RUN --mount=type=secret,id=pwd cd /zwallet && ./configure.sh zcash && ./build.sh

FROM alpine:latest
WORKDIR /root
COPY --from=builder /zwallet/build/app/outputs/bundle/release/app-release.aab ./
5 changes: 5 additions & 0 deletions docker/Dockerfile-builder
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM archlinux:base-devel AS builder

COPY install-deps.sh .

RUN ./install-deps.sh
Binary file added docker/zwallet.jks
Binary file not shown.
35 changes: 35 additions & 0 deletions install-deps.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/sh

mkdir -p /Android/sdk
export ANDROID_SDK_ROOT=/Android/sdk
pacman -Sy --noconfirm unzip jdk8-openjdk git

curl -o sdk-tools.zip https://dl.google.com/android/repository/commandlinetools-linux-7583922_latest.zip
unzip sdk-tools.zip
(cd cmdline-tools/bin &&
yes | ./sdkmanager --sdk_root=$ANDROID_SDK_ROOT --licenses &&
yes | ./sdkmanager --sdk_root=$ANDROID_SDK_ROOT "platform-tools" "platforms;android-30")
rm sdk-tools.zip

curl -o ndk.zip https://dl.google.com/android/repository/android-ndk-r21e-linux-x86_64.zip
(cd Android && unzip ../ndk.zip)
rm ndk.zip

pacman -Sy --noconfirm rustup
rustup install stable
rustup target add aarch64-linux-android armv7-linux-androideabi i686-linux-android x86_64-linux-android
cargo install --force cargo-make

curl -o flutter.tar.xz https://storage.googleapis.com/flutter_infra_release/releases/stable/linux/flutter_linux_2.2.3-stable.tar.xz
tar xvf flutter.tar.xz
rm -f flutter.tar.xz

curl -sSL https://git.io/get-mo -o /usr/bin/mo
chmod +x /usr/bin/mo

mkdir /root/.zcash-params
curl https://download.z.cash/downloads/sapling-output.params -o /root/.zcash-params/sapling-output.params
curl https://download.z.cash/downloads/sapling-spend.params -o /root/.zcash-params/sapling-spend.params

export ANDROID_NDK_HOME=$HOME/Android/android-ndk-r21e
export PATH=$PATH:/flutter/bin
1 change: 1 addition & 0 deletions lib/chart.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import 'package:flutter_palette/flutter_palette.dart';
import 'package:warp_api/warp_api.dart';

import 'store.dart';
import 'main.dart';
Expand Down
2 changes: 1 addition & 1 deletion lib/generated/intl/messages_es.dart
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class MessageLookup extends MessageLookupByLibrary {
"cancel" : MessageLookupByLibrary.simpleMessage("Cancelar"),
"changeAccountName" : MessageLookupByLibrary.simpleMessage("Cambiar nombre de la cuenta"),
"coffee" : MessageLookupByLibrary.simpleMessage("Café"),
"coldStorage" : MessageLookupByLibrary.simpleMessage("Cold Storage"),
"coldStorage" : MessageLookupByLibrary.simpleMessage("Billetera Fría"),
"confirmDeleteAccount" : MessageLookupByLibrary.simpleMessage("¿Está SEGURO de que desea BORRAR esta cuenta? DEBE tener una COPIA DE SEGURIDAD para recuperarla. Esta operación NO es reversible."),
"confs" : MessageLookupByLibrary.simpleMessage("Confs"),
"contacts" : MessageLookupByLibrary.simpleMessage("Contactos"),
Expand Down
2 changes: 0 additions & 2 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,6 @@ List<ElevatedButton> confirmButtons(BuildContext context,
];
}

const DAY_MS = 24 * 3600 * 1000;

List<TimeSeriesPoint<V>> sampleDaily<T, Y, V>(List<T> timeseries,
int start,
int end,
Expand Down
2 changes: 1 addition & 1 deletion lib/restore.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class _RestorePageState extends State<RestorePage> {
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("\u24E8 Wallet"),
title: Text("${coin.symbol} Wallet"),
),
body: Form(
key: _formKey,
Expand Down
3 changes: 2 additions & 1 deletion lib/store.dart
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,8 @@ abstract class _AccountManager with Store {
var cash = 0.0;
var realized = 0.0;
final List<PnL> _pnls = [];
for (var i = 0; i < quotes.length; i++) {
final len = math.min(quotes.length, portfolioTimeSeries.length);
for (var i = 0; i < len; i++) {
final dt = quotes[i].dt;
final price = quotes[i].price;
final balance = portfolioTimeSeries[i].value;
Expand Down
6 changes: 4 additions & 2 deletions packages/warp_api_ffi/lib/warp_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import 'package:ffi/ffi.dart';
import './warp_api_generated.dart';

typedef report_callback = Void Function(Int32);
const DAY_MS = 24 * 3600 * 1000;

class SyncParams {
bool getTx;
Expand Down Expand Up @@ -237,6 +238,7 @@ String shieldTAddrIsolateFn(int account) {
}

int syncHistoricalPricesIsolateFn(String currency) {
final now = DateTime.now().millisecondsSinceEpoch ~/ 1000;
return warp_api_lib.sync_historical_prices(now, 370, currency.toNativeUtf8().cast<Int8>());
final now = DateTime.now();
final today = DateTime.utc(now.year, now.month, now.day);
return warp_api_lib.sync_historical_prices(today.millisecondsSinceEpoch ~/ DAY_MS, 370, currency.toNativeUtf8().cast<Int8>());
}
4 changes: 2 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.0.9+84
version: 1.0.9+86

environment:
sdk: ">=2.9.0 <3.0.0"
Expand Down Expand Up @@ -73,7 +73,7 @@ dev_dependencies:
change_app_package_name: any

flutter_launcher_name:
name: "ZWallet"
name: "YWallet"

flutter_icons:
android: true
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.0.9+84
version: 1.0.9+86

environment:
sdk: ">=2.9.0 <3.0.0"
Expand Down

0 comments on commit 425f43a

Please sign in to comment.