Last active
December 28, 2018 17:33
-
-
Save admhpr/9686672ee4173a5dadd9546349d65bc0 to your computer and use it in GitHub Desktop.
Dockerfile to create a Debian 9 instance
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| version: "3" | |
| services: | |
| server: | |
| build: . | |
| container_name: ansible_test_server | |
| ports: | |
| - "8080:80" | |
| command: bash -c "/usr/sbin/sshd && tail -f /dev/null" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| FROM debian:latest | |
| # Install packages | |
| RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -y install \ | |
| openssh-server \ | |
| apt-utils \ | |
| python3\ | |
| zip \ | |
| unzip \ | |
| sudo | |
| RUN mkdir -p /var/run/sshd && sed -i "s/UsePrivilegeSeparation.*/UsePrivilegeSeparation no/g" /etc/ssh/sshd_config \ | |
| && sed -i 's/PermitRootLogin without-password/PermitRootLogin yes/' /etc/ssh/sshd_config \ | |
| && touch /root/.Xauthority \ | |
| && true | |
| ## Set a default user. Available via runtime flag `--user deploy` | |
| ## Add user to 'staff' group, granting them write privileges to /usr/local/lib/R/site.library | |
| ## User should also have & own a home directory, but also be able to sudo | |
| RUN useradd deploy \ | |
| && passwd -d deploy \ | |
| && mkdir /home/deploy \ | |
| && chown deploy:deploy /home/deploy \ | |
| && addgroup deploy staff \ | |
| && addgroup deploy sudo \ | |
| && true | |
| RUN mkdir -p /root/.ssh | |
| RUN echo "ssh-rsa <your-key-here>" >> /root/.ssh/authorized_keys | |
| RUN chmod 600 -R /root/.ssh | |
| EXPOSE 22 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [live-servers] | |
| <vps-ip> | |
| [test-servers] | |
| <locak-docker-ip> | |
| [test:vars] | |
| ansible_ssh_user=root | |
| [servers:children] | |
| live-servers | |
| test-servers | |
| [test:children] | |
| test-servers | |
| [live:children] | |
| live-servers | |
| [servers:vars] | |
| ansible_private_key_file="/home/adam/.ssh/id_rsa" | |
| ansible_python_interpreter=/usr/bin/python3 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| live: | |
| ansible-playbook --vault-id .vault_pass -i hosts site.yml site.yml --limit live | |
| live-debug: | |
| ansible-playbook --vault-id .vault_pass -i hosts site.yml site.yml -vvv --limit live | |
| test: | |
| ansible-playbook --vault-id .vault_pass -i hosts site.yml --limit test | |
| test-debug: | |
| ansible-playbook --vault-id .vault_pass -i hosts site.yml -vvv --limit test | |
| check: | |
| ansible-playbook --syntax-check --vault-id .vault_pass -i hosts site.yml --limit test | |
| rebuild: | |
| docker-compose build \ | |
| sleep 5 \ | |
| & docker-compose down \ | |
| sleep 5 \ | |
| & docker-compose up -d |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment