Usage:
dev build
dev run --rm projectname rspec
OR
dev run --rm projectname ruby -Ilib:../lib test/test_foo.rb
| version: '2' | |
| services: | |
| projectname: | |
| build: . | |
| image: projectname:dev | |
| stdin_open: true | |
| tty: true | |
| volumes: | |
| - bundler-data:/usr/local/bundle | |
| - .:/srv | |
| volumes: | |
| bundler-data: | |
| driver: local |
| #!/bin/dumb-init /bin/bash | |
| if [ "$(stat -c %u /usr/local/bundle)" = '0' ]; then | |
| chown deploy:deploy /usr/local/bundle | |
| fi | |
| if [ "$(which "$1")" = '' ]; then | |
| if [ "$(ls -A /usr/local/bundle/bin)" = '' ]; then | |
| echo 'command not in path and bundler not initialized' | |
| echo 'running bundle install' | |
| gosu deploy bundle install | |
| fi | |
| fi | |
| if [ "$1" = 'bundle' ]; then | |
| set -- gosu deploy "$@" | |
| elif [ "$1" = 'ruby' ]; then | |
| set -- gosu deploy "$@" | |
| gosu deploy bash -c 'bundle check || bundle install' | |
| elif ls /usr/local/bundle/bin | grep -q "\b$1\b"; then | |
| set -- gosu deploy bundle exec "$@" | |
| gosu deploy bash -c 'bundle check || bundle install' | |
| fi | |
| exec "$@" |
| FROM outstand/ruby-base:2.4.2-alpine | |
| RUN addgroup -S deploy && \ | |
| adduser -S -G deploy deploy && \ | |
| mv /usr/local/bin/rake /usr/local/bin/rake.back && \ | |
| apk add --no-cache bash build-base linux-headers tzdata curl curl-dev less && \ | |
| apk upgrade --no-cache | |
| WORKDIR /srv | |
| COPY . /srv/ | |
| RUN chown -R deploy:deploy /srv | |
| COPY docker-entrypoint.sh /docker-entrypoint.sh | |
| ENTRYPOINT ["/docker-entrypoint.sh"] | |
| CMD ["sh"] |