diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..c56edde --- /dev/null +++ b/Dockerfile @@ -0,0 +1,24 @@ +# vim:set ft=dockerfile: + +FROM ruby:2.7-alpine as app + +LABEL maintainer="Peter Hamilton " \ + description="ROM-LDAP with Rails" + +RUN apk add --no-cache --no-progress \ + build-base \ + openldap-clients \ + sqlite-dev \ + tzdata + +WORKDIR /usr/app + +VOLUME /usr/app + +EXPOSE 3000 + +COPY docker-entrypoint.sh / + +RUN chmod +x /docker-entrypoint.sh + +ENTRYPOINT ["/docker-entrypoint.sh"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..1f1fbf9 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,32 @@ +--- +version: '2.4' + + +# https://docs.docker.com/compose/networking/#use-a-pre-existing-network +# $ docker network ls +networks: + default: + external: + name: docker_rom-ldap-network + + +services: + rom-ldap-rails: + container_name: rom_ldap_rails + build: + context: . + volumes: + - .:/usr/app + - ./tmp/bundler:/usr/local/bundle + ports: + - 3002:3000 + environment: + - TZ + - LOCALE + - LDAPURI=ldap://cn=admin,dc=rom,dc=ldap:topsecret@openldap + - RAILS_ENV=development + command: rails server + tty: true + stdin_open: true + networks: + - default diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh new file mode 100644 index 0000000..1205e03 --- /dev/null +++ b/docker-entrypoint.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +set -e + +echo "Ruby version:" +ruby --version + +echo "Installing ruby gems:" +gem install bundler --no-document +bundle check || bundle install + +echo "Create and migrate database:" +bundle exec rake db:migrate + +exec bundle exec "$@"