提交 2c6e4c70 编写于 作者: M Mislav Marohnić

[test] Add ability to run tests in a Docker container

上级 03533a16
*
!Gemfile
!Gemfile.lock
\ No newline at end of file
FROM ruby:2.6
RUN apt-get update \
&& apt-get install -y sudo golang --no-install-recommends
RUN apt-get purge --auto-remove -y curl \
&& rm -rf /var/lib/apt/lists/*
RUN groupadd -r app && useradd -r -g app -G sudo app \
&& mkdir -p /home/app && chown -R app:app /home/app
RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
USER app
# throw errors if Gemfile has been modified since Gemfile.lock
RUN bundle config --global frozen 1
WORKDIR /home/app/workdir
COPY Gemfile Gemfile.lock ./
RUN bundle install
ENV LANG C.UTF-8
ENV GOFLAGS -mod=vendor
ENV USER app
#!/bin/bash
# Usage: script/docker [<cucumber-args>]
set -e
container=hub-test
workdir=/home/app/workdir
docker build -t "$container" .
docker run -it --rm -v "$PWD":"$workdir" -w "$workdir" "$container" \
/bin/bash -c "
# Enables running WEBrick server (see local_server.rb)
# https://stackoverflow.com/a/45899937/11687
cp /etc/hosts /tmp/hosts.new \
&& sed -i 's/::1\\tlocalhost/::1/' /tmp/hosts.new \
&& sudo cp -f /tmp/hosts.new /etc/hosts || exit 1
go test ./...
bundle exec cucumber $@
"
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册