├── .github └── workflows │ └── test.yml ├── LICENSE ├── README.md ├── build.sh ├── ci ├── ci-tag ├── common_utils.sh ├── layers ├── base.sh ├── debian-buster.sh ├── debian-stretch.sh ├── nim.sh ├── ubuntu-2204.sh ├── ui.sh └── wasm.sh ├── postinstall.sh └── preinstall.sh /.github/workflows/test.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: 4 | push: 5 | schedule: 6 | - cron: '0 0 * * *' 7 | 8 | jobs: 9 | Build: 10 | if: | 11 | !contains(github.event.head_commit.message, '[skip ci]') 12 | strategy: 13 | fail-fast: false 14 | matrix: 15 | builds: 16 | - debian-buster.base debian-buster.base.nim debian-buster.base.nim.ui 17 | # - debian-stretch.base debian-stretch.base.nim debian-stretch.base.nim.ui 18 | - ubuntu-2204.base ubuntu-2204.base.nim 19 | 20 | env: 21 | DOCKER_USER: ${{ secrets.DOCKER_USER }} 22 | DOCKER_PASS: ${{ secrets.DOCKER_PASS }} 23 | 24 | name: ${{matrix.builds}} 25 | runs-on: ubuntu-latest 26 | steps: 27 | - uses: actions/checkout@v3 28 | 29 | - name: build 30 | run: | 31 | ./ci ${{matrix.builds}} 32 | 33 | # - name: Tags 34 | # shell: bash 35 | # run: | 36 | # ./ci-tag debian-buster-pre-nim debian-buster.base 37 | # ./ci-tag debian-buster-nim-base debian-buster.base.nim 38 | # ./ci-tag debian-pre-nim debian-buster.base 39 | # ./ci-tag nim-base debian-buster.base.nim 40 | # ./ci-tag nim-ui-base debian-buster.base.nim.ui 41 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Yuriy Glukhov 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # nim-docker [![CI](https://github.com/yglukhov/nim-docker/actions/workflows/test.yml/badge.svg)](https://github.com/yglukhov/nim-docker/actions/workflows/test.yml) 2 | 3 | This is a helper repo for auto building docker image with latest [Nim](https://github.com/nim-lang/Nim) devel version. 4 | 5 | ```sh 6 | docker run yglukhov/debian-buster.base.nim nim --version 7 | 8 | ``` 9 | -------------------------------------------------------------------------------- /build.sh: -------------------------------------------------------------------------------- 1 | 2 | OWNER_ACC=yglukhov 3 | MAINTAINER="Yuriy Glukhov " 4 | 5 | set -e 6 | 7 | buildAndPush() { 8 | id=$1 9 | parentLayer=$(echo $id | sed 's/\.[^.]*$//') 10 | thisLayer=$(echo $id | sed 's/^.*\.\([^.]*\)$/\1/') 11 | 12 | buildDir=$(mktemp -dt docker-build-XXXXXX) 13 | thisDir=$(dirname $0) 14 | dockerfile="$buildDir/Dockerfile" 15 | installfile="$buildDir/install.sh" 16 | 17 | if echo $parentLayer | grep '\.' > /dev/null 18 | then 19 | echo FROM $OWNER_ACC/$parentLayer > "$dockerfile" 20 | else 21 | cp "$thisDir/layers/$parentLayer.sh" "$dockerfile" 22 | fi 23 | 24 | echo MAINTAINER $MAINTAINER >> "$dockerfile" 25 | cat "$thisDir/layers/$thisLayer.sh" | sed -e '/# SCRIPT/,$d' >> "$dockerfile" 26 | echo '. /common_utils.sh' > "$installfile" 27 | echo 'set -ex' >> "$installfile" 28 | cat "$thisDir/layers/$thisLayer.sh" | sed -e '1,/# SCRIPT/d' >> "$installfile" 29 | cp "$thisDir/preinstall.sh" "$thisDir/postinstall.sh" "$thisDir/common_utils.sh" "$buildDir" 30 | 31 | chmod +x "$buildDir"/*.sh 32 | echo 'ADD *install.sh common_utils.sh /' >> "$dockerfile" 33 | echo 'RUN /preinstall.sh && /install.sh && /postinstall.sh' >> "$dockerfile" 34 | 35 | docker build -t $OWNER_ACC/$id "$buildDir" 36 | docker push $OWNER_ACC/$id 37 | } 38 | 39 | if [ $# = 0 ] 40 | then 41 | echo "Usage: $(basename $0) dir1 ..." 42 | exit 1 43 | fi 44 | 45 | for a in $* 46 | do 47 | if echo $a | grep '\?' > /dev/null 48 | then 49 | if [ "$BUILD_ALL" = "true" ] 50 | then 51 | buildAndPush $(echo $a | sed 's/\?//') 52 | fi 53 | else 54 | buildAndPush $a 55 | fi 56 | done 57 | 58 | -------------------------------------------------------------------------------- /ci: -------------------------------------------------------------------------------- 1 | 2 | set -e 3 | docker logout 4 | echo "$DOCKER_PASS" | docker login --password-stdin "--username=$DOCKER_USER" 5 | $(dirname $0)/build.sh $* 6 | docker logout 7 | 8 | -------------------------------------------------------------------------------- /ci-tag: -------------------------------------------------------------------------------- 1 | 2 | set -ex 3 | 4 | echo "$DOCKER_PASS" | docker login --password-stdin "--username=$DOCKER_USER" 5 | docker pull yglukhov/$2 6 | docker tag yglukhov/$2 yglukhov/$1 7 | docker push yglukhov/$1 8 | docker logout 9 | 10 | -------------------------------------------------------------------------------- /common_utils.sh: -------------------------------------------------------------------------------- 1 | 2 | apt_install() { 3 | while ! apt-get update; do true; done 4 | while ! apt-get install -y $*; do true; done 5 | } 6 | 7 | -------------------------------------------------------------------------------- /layers/base.sh: -------------------------------------------------------------------------------- 1 | 2 | # SCRIPT 3 | 4 | apt_install gcc g++ mercurial git libssl-dev curl gnupg make 5 | # Install nodejs 15 6 | curl -sL https://deb.nodesource.com/setup_16.x | bash 7 | apt_install nodejs 8 | 9 | echo " IdentityFile ~/.ssh/id_rsa" >> /etc/ssh/ssh_config 10 | mkdir /onStart.d /onQuit.d 11 | 12 | echo '#!/bin/sh 13 | for I in $(ls /onStart.d) 14 | do 15 | . /onStart.d/$I 16 | done 17 | 18 | # Run the command 19 | sh -c "$*" 20 | EXIT_CODE=$? 21 | 22 | for I in $(ls /onQuit.d) 23 | do 24 | . /onQuit.d/$I 25 | done 26 | 27 | exit $EXIT_CODE 28 | ' > /bin/run 29 | 30 | chmod +x /bin/run 31 | 32 | apt-get remove -y curl 33 | 34 | -------------------------------------------------------------------------------- /layers/debian-buster.sh: -------------------------------------------------------------------------------- 1 | FROM debian:buster 2 | -------------------------------------------------------------------------------- /layers/debian-stretch.sh: -------------------------------------------------------------------------------- 1 | FROM debian:stretch 2 | 3 | -------------------------------------------------------------------------------- /layers/nim.sh: -------------------------------------------------------------------------------- 1 | ENV PATH $PATH:/nim/bin:/root/.nimble/bin 2 | 3 | # SCRIPT 4 | export NIM_PATCH_BRANCHES= 5 | 6 | git clone https://github.com/nim-lang/nim.git 7 | cd nim 8 | git remote add yglukhov https://github.com/yglukhov/nim.git 9 | git fetch yglukhov 10 | git config --global user.email "you@example.com" 11 | git config --global user.name "Your Name" 12 | for i in $NIM_PATCH_BRANCHES 13 | do 14 | git merge yglukhov/$i 15 | done 16 | sh build_all.sh 17 | echo echo nim version: $(git rev-parse HEAD) > /onStart.d/005-nim-version.sh 18 | chmod +x /onStart.d/005-nim-version.sh 19 | cd ./dist/nimble 20 | echo echo nimble version: $(git rev-parse HEAD) > /onStart.d/006-nimble-version.sh 21 | chmod +x /onStart.d/006-nimble-version.sh 22 | cd ../.. 23 | rm -rf ./nimcache ./compiler/nimcache ./csources ./dist ./.git 24 | cd .. 25 | 26 | -------------------------------------------------------------------------------- /layers/ubuntu-2204.sh: -------------------------------------------------------------------------------- 1 | FROM ubuntu:22.04 2 | -------------------------------------------------------------------------------- /layers/ui.sh: -------------------------------------------------------------------------------- 1 | ENV LD_LIBRARY_PATH /usr/lib/x86_64-linux-gnu/ 2 | ENV DISPLAY :1.0 3 | 4 | # SCRIPT 5 | 6 | apt_install fonts-dejavu-core xvfb libsdl2-dev libx11-dev libgtk-3-0 iceweasel default-jre libgdk-pixbuf2.0-dev 7 | echo 'Xvfb :1 -screen 0 1024x768x16 +extension RANDR &' > /onStart.d/010-start-x-server.sh 8 | 9 | -------------------------------------------------------------------------------- /layers/wasm.sh: -------------------------------------------------------------------------------- 1 | ENV PATH $PATH:/root/.cargo/bin 2 | 3 | # SCRIPT 4 | apt_install cmake curl libc6-dev-i386 5 | tag=release_80 6 | 7 | git clone --depth 1 --branch $tag https://github.com/llvm-mirror/llvm.git 8 | cd llvm/tools 9 | git clone --depth 1 --branch $tag https://github.com/llvm-mirror/clang 10 | git clone --depth 1 --branch $tag https://github.com/llvm-mirror/lld 11 | cd .. 12 | mkdir build 13 | cd build 14 | #-DLLVM_LINK_LLVM_DYLIB=ON 15 | cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr -DLLVM_TARGETS_TO_BUILD=WebAssembly .. 16 | make -j 4 install 17 | 18 | cd ../.. 19 | rm -rf llvm 20 | 21 | # Setup rust 22 | while ! curl https://sh.rustup.rs -sSf | sh -s -- -y 23 | do 24 | true 25 | done 26 | 27 | cargo install --git "https://github.com/alexcrichton/wasm-gc.git" 28 | 29 | git clone --recursive https://github.com/WebAssembly/wabt 30 | cd wabt 31 | make gcc-release 32 | cp bin/* /usr/bin 33 | cd .. 34 | rm -rf wabt 35 | 36 | 37 | apt-get remove -y cmake curl 38 | -------------------------------------------------------------------------------- /postinstall.sh: -------------------------------------------------------------------------------- 1 | 2 | cleanup() { 3 | apt-get autoremove -y 4 | apt-get clean all 5 | rm -rf /var/lib/apt/lists/* /usr/share/doc /usr/share/man /usr/share/locale ~/.cache /preinstall.sh /install.sh /common_utils.sh 6 | rm -rf /postinstall.sh 7 | } 8 | 9 | cleanup 10 | 11 | -------------------------------------------------------------------------------- /preinstall.sh: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yglukhov/nim-docker/7b522d989e92ecb601099261b0b921749d5795dc/preinstall.sh --------------------------------------------------------------------------------