From d3a46da63b6e8f3037e320c759da9114ac276df6 Mon Sep 17 00:00:00 2001 From: asonix Date: Tue, 28 Jan 2020 13:56:27 -0600 Subject: [PATCH] Update build process --- Makefile | 5 +-- container/Dockerfile-deps-arm64v8 | 70 +++++++++++++++++++++++++++++++ container/build-images.sh | 4 +- container/pull-containers.sh | 13 ------ container/push-containers.sh | 2 +- 5 files changed, 74 insertions(+), 20 deletions(-) create mode 100644 container/Dockerfile-deps-arm64v8 delete mode 100755 container/pull-containers.sh diff --git a/Makefile b/Makefile index 083ea923c..d9844dcb0 100644 --- a/Makefile +++ b/Makefile @@ -3,10 +3,7 @@ DEPS_IMAGE_NAME = "asonix/masto-deps" masto: images push-images -all: pull-base deps push-deps images push-images - -pull-base: - ./container/pull-containers.sh +all: deps push-deps images push-images deps: ./container/build-images.sh container/Dockerfile-deps $(DEPS_IMAGE_NAME) diff --git a/container/Dockerfile-deps-arm64v8 b/container/Dockerfile-deps-arm64v8 new file mode 100644 index 000000000..56c39be30 --- /dev/null +++ b/container/Dockerfile-deps-arm64v8 @@ -0,0 +1,70 @@ +FROM arm64v8/ubuntu:18.04 + +# Install Node +ENV NODE_VER="12.11.1" +ENV ARCH="arm64" +RUN echo "Etc/UTC" > /etc/localtime && \ + apt update && \ + apt -y install wget python && \ + cd ~ && \ + wget https://nodejs.org/download/release/v$NODE_VER/node-v$NODE_VER-linux-$ARCH.tar.gz && \ + tar xf node-v$NODE_VER-linux-$ARCH.tar.gz && \ + rm node-v$NODE_VER-linux-$ARCH.tar.gz && \ + mv node-v$NODE_VER-linux-$ARCH /opt/node + +# Install jemalloc +ENV JE_VER="5.2.1" +RUN apt update && \ + apt -y install make autoconf gcc g++ && \ + cd ~ && \ + wget https://github.com/jemalloc/jemalloc/archive/$JE_VER.tar.gz && \ + tar xf $JE_VER.tar.gz && \ + cd jemalloc-$JE_VER && \ + ./autogen.sh && \ + ./configure --prefix=/opt/jemalloc && \ + make -j$(nproc) > /dev/null && \ + make install_bin install_include install_lib + +# Install ruby +ENV RUBY_VER="2.6.5" +ENV CPPFLAGS="-I/opt/jemalloc/include" +ENV LDFLAGS="-L/opt/jemalloc/lib/" +RUN apt update && \ + apt -y install build-essential \ + bison libyaml-dev libgdbm-dev libreadline-dev \ + libncurses5-dev libffi-dev zlib1g-dev libssl-dev && \ + cd ~ && \ + wget https://cache.ruby-lang.org/pub/ruby/${RUBY_VER%.*}/ruby-$RUBY_VER.tar.gz && \ + tar xf ruby-$RUBY_VER.tar.gz && \ + cd ruby-$RUBY_VER && \ + ./configure --prefix=/opt/ruby \ + --with-jemalloc \ + --with-shared \ + --disable-install-doc && \ + ln -s /opt/jemalloc/lib/* /usr/lib/ && \ + make -j$(nproc) > /dev/null && \ + make install + +ENV PATH="${PATH}:/opt/ruby/bin:/opt/node/bin" + +RUN npm install -g yarn && \ + gem install bundler && \ + apt update && \ + apt -y install git libicu-dev libidn11-dev \ + libpq-dev libprotobuf-dev protobuf-compiler + +# Add tini +ENV TINI_VERSION="0.18.0" +ENV TINI_ARCH="arm64" +ADD https://github.com/krallin/tini/releases/download/v${TINI_VERSION}/tini-${TINI_ARCH} /tini +ADD https://github.com/krallin/tini/releases/download/v${TINI_VERSION}/tini-${TINI_ARCH}.asc /tini.asc + +RUN apt update && \ + apt -y --no-install-recommends install gpg gpg-agent dirmngr + +RUN gpg --batch \ + --keyserver hkp://p80.pool.sks-keyservers.net:80 \ + --recv-keys 595E85A6B1B4779EA4DAAEC70B588DFF0527A9B7 && \ + gpg --batch --verify /tini.asc /tini + +RUN chmod +rx /tini diff --git a/container/build-images.sh b/container/build-images.sh index 865f2b534..b21105ff6 100755 --- a/container/build-images.sh +++ b/container/build-images.sh @@ -18,7 +18,7 @@ require_input() { require_input "$SOURCE" "Dockerfile" require_input "$TAG" "container tag" -ARCHITECTURES=('arm64v8' 'arm32v7' 'amd64') +ARCHITECTURES=('arm64v8' 'amd64') for architecture in "${ARCHITECTURES[@]}"; do cp "$SOURCE" "$SOURCE-$architecture" @@ -36,7 +36,7 @@ for architecture in "${ARCHITECTURES[@]}"; do sed -i'' 's/amd64/arm64/g' "$SOURCE-$architecture" # for tini fi - docker build -f "$SOURCE-$architecture" -t "$TAG:$architecture" . + docker build --pull --no-cache -f "$SOURCE-$architecture" -t "$TAG:$architecture" . rm "$SOURCE-$architecture" done diff --git a/container/pull-containers.sh b/container/pull-containers.sh deleted file mode 100755 index 1a9a3a313..000000000 --- a/container/pull-containers.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env bash - -set -xe - -architectures=('arm64v8' 'arm32v7' 'amd64') - -for architecture in "${architectures[@]}"; do - if [ "$1" == "" ]; then - docker pull "$architecture/ubuntu:18.04" - else - docker pull "$1:$architecture" - fi -done diff --git a/container/push-containers.sh b/container/push-containers.sh index 613a5ec13..2ea7cc459 100755 --- a/container/push-containers.sh +++ b/container/push-containers.sh @@ -16,7 +16,7 @@ require_input() { require_input "$TAG" "container tag" -ARCHITECTURES=('arm64v8' 'arm32v7' 'amd64') +ARCHITECTURES=('arm64v8' 'amd64') for arch in "${ARCHITECTURES[@]}"; do docker push "$TAG:$arch"