Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplified Docker dev setup #167

Draft
wants to merge 1 commit into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
version: '3.1'

services:

vm:
build:
context: ./docker/vm
container_name: vm
ports:
- 8000:8000
- 8080:8080
- 3306:3306
- 5432:5432
- 8983:8983
- 8161:8161
networks:
- islandora
privileged: true
volumes:
- keys:/root/.ssh

ansible:
container_name: ansible
build:
context: ./docker/ansible
networks:
- islandora
depends_on:
- vm
volumes:
- keys:/root/.ssh
- ./:/root/playbook:Z

networks:
islandora:
driver: bridge

volumes:
keys:
driver: local

17 changes: 17 additions & 0 deletions docker/ansible/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM centos:7.6.1810

ENV ISLANDORA_DISTRO="centos/7" \
ANSIBLE_CONFIG=/root/playbook/ansible.cfg

WORKDIR /root/playbook

RUN yum -y install epel-release && \
yum -y install git openssl openssh-clients python-pip python-devel python

RUN pip install ansible==2.8.7

COPY entrypoint.sh /bin/

RUN chmod 700 /bin/entrypoint.sh

ENTRYPOINT [ "/bin/entrypoint.sh" ]
18 changes: 18 additions & 0 deletions docker/ansible/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/sh

ssh-keyscan -H vm > /root/.ssh/known_hosts

ansible-galaxy install --role-file=/root/playbook/requirements.yml --roles-path=roles/external

ansible-playbook \
-u root \
-i ./inventory/vagrant/hosts \
-e '@./docker/extra-vars.yml' \
-e ansible_ssh_host='vm' \
-e int_host='vm' \
--private-key /root/.ssh/id_rsa \
./playbook.yml \
-l default

## Keeps the container running forever, after Ansible finishes
tail -f /dev/null
57 changes: 57 additions & 0 deletions docker/extra-vars.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
---

# used to override variables in the playbook via the extra vars commandline
# option. Add your site specific vars here. If you need values from
# the terraform script, we will need to template them correctly.
#
# Thoughts on templating:
# - add the vars here with a default value and use subsequent calls on the
# provisioner call in terraform to override.
#
# - can we use functions in this file to do filters/templating? Needs
# testing.


# internal_hostname - "-e int_host='somedomain'" can be passed via the cmdline to template externaly
internal_hostname: "{{ int_host | default('localhost') }}"

# external_hostname - "-e ext_host='somedomain'" can be passed via the cmdline to template externally
external_hostname: "{{ ext_host | default('localhost') }}"

# ansible mods
ansible_host: vm
ansible_port: 22
ansible_ssh_private_key_file: /root/.ssh/id_rsa

# php mods
php_upload_max_filesize: 1024M
php_post_max_size: 1024M
php_max_execution_time: 300

# TODO: Needs templating, maybe. localhost may be ok.
openseadragon_iiiv_server: "http://{{internal_hostname}}:8080/cantaloupe/iiif/2"

# apache stuff
apache_listen_port: "{{ ext_port | default('8000')}}"
apache_vhosts:
- servername: "{{external_hostname}}"
documentroot: "/var/www/html/drupal/web"
allow_override: All
options: -Indexes +FollowSymLinks

# drupal stuff
drupal_domain: "{{external_hostname}}"
drupal_trusted_hosts:
- ^localhost$
- "{{ hostvars[groups['webserver'][0]].ansible_host }}"
- "{{external_hostname}}"

# crayfish stuff
crayfish_drupal_base_url: "http://{{ internal_hostname }}:{{ apache_listen_port }}"
crayfish_gemini_base_url: "http://{{ internal_hostname }}:{{ apache_listen_port }}/gemini"

# karaf stuff
alpaca_milliner_base_url: "http://{{ internal_hostname }}:{{ apache_listen_port }}/milliner/"
alpaca_gemini_base_url: "http://{{ internal_hostname }}:{{ apache_listen_port }}/gemini/"
alpaca_houdini_base_url: "http://{{ internal_hostname }}:{{ apache_listen_port }}/houdini"
alpaca_homarus_base_url: "http://{{ internal_hostname }}:{{ apache_listen_port }}/homarus"
40 changes: 40 additions & 0 deletions docker/vm/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
FROM centos:7.6.1810

ENV container docker

COPY sestatus /bin/

RUN chmod 700 /bin/sestatus

RUN (cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i == systemd-tmpfiles-setup.service ] || rm -f $i; done); \
rm -f /lib/systemd/system/multi-user.target.wants/*;\
rm -f /etc/systemd/system/*.wants/*;\
rm -f /lib/systemd/system/local-fs.target.wants/*; \
rm -f /lib/systemd/system/sockets.target.wants/*udev*; \
rm -f /lib/systemd/system/sockets.target.wants/*initctl*; \
rm -f /lib/systemd/system/basic.target.wants/*;\
rm -f /lib/systemd/system/anaconda.target.wants/*;

RUN yum -y install \
--setopt=tsflags=nodocs \
--disableplugin=fastestmirror \
openssh-clients \
openssh-server \
openssl \
sudo \
initscripts

# Authorize SSH Host
RUN mkdir -p /root/.ssh && \
chmod 0700 /root/.ssh


# Add the keys and set permissions
RUN cat /dev/zero | ssh-keygen -q -N "" && \
chmod 600 /root/.ssh/id_rsa && \
chmod 600 /root/.ssh/id_rsa.pub && \
cat /root/.ssh/id_rsa.pub > /root/.ssh/authorized_keys

VOLUME [ "/sys/fs/cgroup" ]

CMD ["/usr/sbin/init"]
3 changes: 3 additions & 0 deletions docker/vm/sestatus
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh

echo "Current mode: permissive"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this actually disable SELinux or just the reporting functions?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since SELinux isn't really running in Docker containers, this just tricks Ansible into passing its "is selinux set up correctly?" test.