I managed to puzzle together a Dockerfile from various sources and some on my own. There are two images: one base for travis
being available and one project specific for "org/repo" GitHub project (make sure occurrences are replaced with a real project name). It uses the local uncommitted repository version (hence the sed
s). After travis-local-build
is up and running ./build.sh
will trigger a CI build similar to travis-ci.org.
Dockerfile.travis-local
#!docker build -f Dockerfile.travis-local -t travis-local .
FROM travisci/ci-amethyst:packer-1512508255-986baf0
USER travis
WORKDIR /home/travis
RUN git clone https://github.com/travis-ci/travis-build.git
WORKDIR travis-build
RUN bash -lc "gem install travis"
RUN bash -lc travis # to create ~/.travis
RUN ln -s $(pwd) ~/.travis/travis-build
RUN bash -lc "bundle install"
#RUN bash -lc "bundler add travis"
RUN bash -lc "bundler binstubs travis"
RUN echo alias travis="~/.travis/travis-build/bin/travis" >> ~/.bashrc
Dockerfile.travis-local-build
#!docker build -f Dockerfile.travis-local-build -t travis-local-build . && docker run -ti travis-local-build
FROM travis-local
USER travis
WORKDIR /home/travis/build
ADD --chown=travis . org/repo
WORKDIR org/repo
RUN chmod +x gradlew
# Alias not recognized, but in interactive mode `travis compile` works without path.
RUN bash -lc "~/.travis/travis-build/bin/travis compile --no-interactive > build.sh"
RUN sed -re 's/^.*travis_wait_for_network '\''.*$/echo DISABLED &/mg' build.sh --in-place
RUN sed -re 's/^.*apt-get update.*$/echo DISABLED &/mg' build.sh --in-place
RUN sed -re 's/^.*travis_cmd git.*(fetch|reset|checkout).*$/echo DISABLED &/mg' build.sh --in-place
RUN chmod +x build.sh
WORKDIR /home/travis/build
RUN sudo ln -s org/repo/build.sh build.sh
CMD ["bash"]
Disclaimer: I'm new to Docker, only been using it for a few hours, so I might have gotten some concepts wrong. Any pointers appreciated in comments.
travis-build
will convert.travis.yml
tobuild.sh
. What's the problem you're having with it? – набиячлэвэли~/.travis/travis-build/bin/travis compile
but at least on my case it did not wrok. I've an unrecoverable error despite having a clean.travis.yml
based ontravis lint
. – Sik