diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..381b7b7 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,5 @@ +sudo: required +services: + - docker +script: + - docker login "--password=$DOCKER_PASS" "--username=$DOCKER_USER" && ./build.sh && docker logout diff --git a/README.md b/README.md index fe977a4..09d5d08 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,14 @@ -# nim-docker -Nim docker images used to build Status nim projects +# nim-docker [![Build Status](https://travis-ci.org/status-im/nim-docker.svg?branch=master)](https://travis-ci.org/status-im/nim-docker) + +This is a helper repo for auto building docker image with latest [Nim](https://github.com/nim-lang/Nim) devel version. In order to setup [Travis CI](https://travis-ci.org) for your project using this image, copy the following lines to your `.travis.yml` file in the root of your repository: +```yml +sudo: required +services: + - docker +before_install: + - docker pull statusteam/nim-base +script: + - docker run statusteam/nim-base nim --version + - docker run -v "$(pwd):/project" -w /project statusteam/nim-base nimble test +``` +Also make sure to enable your project in [Travis CI](https://travis-ci.org). This configuration will run `nimble test` in the root of your repository. diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..e72dc74 --- /dev/null +++ b/build.sh @@ -0,0 +1,14 @@ + +set -ev + +buildAndPush() { + docker build -t statusteam/$1 $1 + docker push statusteam/$1 +} + +if [ "$1" = "all" -o "$BUILD_ALL" = "true" ] +then + buildAndPush debian-pre-nim +fi + +buildAndPush nim-base diff --git a/debian-pre-nim/Dockerfile b/debian-pre-nim/Dockerfile new file mode 100644 index 0000000..0019f17 --- /dev/null +++ b/debian-pre-nim/Dockerfile @@ -0,0 +1,14 @@ +FROM debian:stretch +MAINTAINER Yuriy Glukhov +ADD run.sh /bin/run +RUN while ! apt-get update; do true; done \ + && while ! apt-get install -y gcc g++ mercurial git nodejs libssl-dev; do true; done \ + && echo " IdentityFile ~/.ssh/id_rsa" >> /etc/ssh/ssh_config \ + && mkdir /onStart.d /onQuit.d \ + && echo "CLEANUP" \ + && apt-get autoremove -y \ + && apt-get clean all \ + && rm -rf /var/lib/apt/lists/* \ + && rm -rf /usr/share/doc \ + && rm -rf /usr/share/man \ + && rm -rf /usr/share/locale diff --git a/debian-pre-nim/run.sh b/debian-pre-nim/run.sh new file mode 100755 index 0000000..3183be1 --- /dev/null +++ b/debian-pre-nim/run.sh @@ -0,0 +1,16 @@ +#!/bin/sh +for I in $(ls /onStart.d) +do + . /onStart.d/$I +done + +# Run the command +sh -c "$*" +EXIT_CODE=$? + +for I in $(ls /onQuit.d) +do + . /onQuit.d/$I +done + +exit $EXIT_CODE diff --git a/nim-base/Dockerfile b/nim-base/Dockerfile new file mode 100644 index 0000000..2c0e24c --- /dev/null +++ b/nim-base/Dockerfile @@ -0,0 +1,26 @@ +FROM yglukhov/debian-pre-nim +MAINTAINER Yuriy Glukhov +ENV PATH $PATH:/nim/bin:/root/.nimble/bin +#ENV NIM_PATCH_BRANCHES my-patch +RUN git clone https://github.com/nim-lang/nim.git \ + && cd nim \ + && git remote add yglukhov https://github.com/yglukhov/nim.git \ + && git fetch yglukhov \ + && git config --global user.email "you@example.com" \ + && git config --global user.name "Your Name" \ + && for i in $NIM_PATCH_BRANCHES; do git merge yglukhov/$i; done \ + && git clone --depth 1 https://github.com/nim-lang/csources.git \ + && cd csources \ + && sh build.sh \ + && cd .. \ + && nim c koch \ + && ./koch boot -d:release \ + && ./koch nimble \ + && echo echo nim version: $(git rev-parse HEAD) > /onStart.d/005-nim-version.sh \ + && chmod +x /onStart.d/005-nim-version.sh \ + && cd ./dist/nimble \ + && echo echo nimble version: $(git rev-parse HEAD) > /onStart.d/006-nimble-version.sh \ + && chmod +x /onStart.d/006-nimble-version.sh \ + && cd ../.. \ + && rm -rf ./nimcache ./compiler/nimcache ./csources ./dist ./.git \ + && cd ..