-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#17 implement deployment scripts with docker and ansible
- Loading branch information
1 parent
83c8ca9
commit d40980f
Showing
14 changed files
with
293 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
.idea | ||
*.pyc | ||
__pycache__ | ||
resources | ||
out | ||
logs | ||
.git |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ | |
__pycache__ | ||
resources | ||
out | ||
logs |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/usr/bin/env ansible-playbook | ||
- hosts: all | ||
vars: | ||
src_destination: ~/derek | ||
use_gpu: "false" | ||
gpu_options: "all" | ||
command_to_run: | ||
postfix: "{{ 'gpu' if (use_gpu == 'true') else 'cpu' }}" | ||
tasks: | ||
- name: Get absolute path | ||
command: echo "{{ src_destination }}" | ||
register: abs_path | ||
- name: Set absolute path | ||
set_fact: | ||
src_abs_destination: "{{ abs_path.stdout }}" | ||
- name: Build container | ||
command: docker build . -f "dockerfiles/Dockerfile.{{ postfix }}" -t "derek-{{ postfix }}" | ||
become: true | ||
args: | ||
chdir: "{{ src_abs_destination }}" | ||
- name: Run cpu container | ||
command: > | ||
docker run -d -v "{{ src_abs_destination }}/resources":/derek/resources | ||
-v "{{ src_abs_destination }}/out":/derek/out -v "{{ src_abs_destination }}/logs":/derek/logs | ||
derek-cpu /bin/bash -c "cd /derek; {{ command_to_run }}" | ||
become: true | ||
args: | ||
chdir: "{{ src_abs_destination }}" | ||
when: use_gpu != 'true' | ||
- name: Run gpu container | ||
command: > | ||
docker run --gpus "{{ gpu_options }}" -d -v "{{ src_abs_destination }}/resources":/derek/resources | ||
-v "{{ src_abs_destination }}/out":/derek/out -v "{{ src_abs_destination }}/logs":/derek/logs | ||
derek-gpu /bin/bash -c "cd /derek; {{ command_to_run }}" | ||
become: true | ||
args: | ||
chdir: "{{ src_abs_destination }}" | ||
when: use_gpu == 'true' |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/usr/bin/env ansible-playbook | ||
- hosts: all | ||
vars: | ||
src_destination: ~/derek | ||
fetch_directory_name: out | ||
tasks: | ||
- name: Fetch results | ||
synchronize: | ||
src: "{{ src_destination }}/out/" | ||
dest: "../{{ fetch_directory_name }}" | ||
mode: pull |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/usr/bin/env ansible-playbook | ||
- hosts: all | ||
become: true | ||
tasks: | ||
- name: Add Docker GPG key | ||
apt_key: url=https://download.docker.com/linux/ubuntu/gpg | ||
|
||
- name: Install basic list of packages | ||
apt: | ||
name: ['apt-transport-https','ca-certificates','curl','gnupg2','software-properties-common'] | ||
state: present | ||
update_cache: yes | ||
|
||
- name: Add Docker APT repository | ||
apt_repository: | ||
repo: deb [arch=amd64] https://download.docker.com/linux/{{ansible_distribution|lower}} {{ansible_distribution_release}} stable | ||
|
||
- name: Install Docker packages | ||
apt: | ||
name: ['docker-ce','docker-ce-cli','containerd.io'] | ||
state: present |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/usr/bin/env ansible-playbook | ||
- hosts: all | ||
become: true | ||
tasks: | ||
- name: Add nvidia-docker GPG key | ||
apt_key: url=https://nvidia.github.io/nvidia-docker/gpgkey | ||
|
||
- name: Get nvidia-docker list | ||
get_url: | ||
url: "https://nvidia.github.io/nvidia-docker/{{ hostvars[inventory_hostname].ansible_distribution|lower}}\ | ||
{{ hostvars[inventory_hostname].ansible_distribution_version }}/nvidia-docker.list" | ||
dest: "/etc/apt/sources.list.d/nvidia-docker.list" | ||
|
||
- name: Install nvidia-container-toolkit | ||
apt: | ||
name: ['nvidia-container-toolkit'] | ||
state: present | ||
update_cache: yes | ||
|
||
- name: Restart docker | ||
systemd: | ||
name: docker | ||
state: restarted |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/usr/bin/env ansible-playbook | ||
- hosts: all | ||
vars: | ||
src_destination: ~/derek | ||
tasks: | ||
- name: Get absolute path | ||
command: echo "{{ src_destination }}" | ||
register: abs_path | ||
- name: Set absolute path | ||
set_fact: | ||
src_abs_destination: "{{ abs_path.stdout }}" | ||
|
||
- name: Delete resources directory | ||
file: | ||
path: "{{ src_abs_destination }}/resources/" | ||
state: absent | ||
become: true |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/usr/bin/env ansible-playbook | ||
- hosts: all | ||
vars: | ||
src_destination: ~/derek | ||
tasks: | ||
- name: Get absolute path | ||
command: echo "{{ src_destination }}" | ||
register: abs_path | ||
- name: Set absolute path | ||
set_fact: | ||
src_abs_destination: "{{ abs_path.stdout }}" | ||
|
||
- name: Delete out directory | ||
file: | ||
path: "{{ src_abs_destination }}/out/" | ||
state: absent | ||
become: true |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#!/usr/bin/env ansible-playbook | ||
- hosts: all | ||
vars: | ||
src_destination: ~/derek | ||
tasks: | ||
- name: Create directory | ||
file: | ||
path: "{{ src_destination }}" | ||
state: directory | ||
|
||
- name: Upload main srcs | ||
synchronize: | ||
src: ../derek/ | ||
dest: "{{ src_destination }}/derek" | ||
delete: yes | ||
|
||
- name: Upload tools srcs | ||
synchronize: | ||
src: ../tools/ | ||
dest: "{{ src_destination }}/tools" | ||
delete: yes | ||
|
||
- name: Upload digger srcs | ||
synchronize: | ||
src: ../babylondigger/ | ||
dest: "{{ src_destination }}/babylondigger" | ||
delete: yes | ||
|
||
- name: Upload dockerfiles | ||
synchronize: | ||
src: ../dockerfiles/ | ||
dest: "{{ src_destination }}/dockerfiles" | ||
delete: yes | ||
|
||
- name: Upload resources | ||
synchronize: | ||
src: ../resources/ | ||
dest: "{{ src_destination }}/resources" | ||
delete: yes | ||
|
||
- name: Upload requirements.txt | ||
synchronize: | ||
src: ../requirements.txt | ||
dest: "{{ src_destination }}/requirements.txt" | ||
delete: yes |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
FROM ubuntu:18.04 | ||
MAINTAINER Trifonov Vladislav <trifonov@ispras.ru> | ||
|
||
RUN apt-get update \ | ||
&& DEBIAN_FRONTEND=noninteractive apt-get install -y locales \ | ||
&& sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen \ | ||
&& dpkg-reconfigure --frontend=noninteractive locales \ | ||
&& update-locale LANG=en_US.UTF-8 | ||
ENV LANG en_US.UTF-8 | ||
ENV LANGUAGE en_US:en | ||
ENV LC_ALL en_US.UTF-8 | ||
|
||
RUN apt-get update && apt-get install -qq -y python3 python3-pip | ||
ENV PYTHONPATH $PYTHONPATH:/derek:/derek/babylondigger:/derek/babylondigger/tdozat-parser-v3 | ||
WORKDIR /derek | ||
COPY requirements.txt . | ||
RUN pip3 install -r ./requirements.txt | ||
COPY tools/requirements.txt ./tools/ | ||
RUN pip3 install -r ./tools/requirements.txt | ||
RUN python3 -c "import nltk;nltk.download('punkt')" | ||
|
||
COPY babylondigger ./babylondigger | ||
COPY tools ./tools | ||
COPY derek ./derek |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
FROM nvidia/cuda:10.0-cudnn7-devel-ubuntu18.04 | ||
MAINTAINER Trifonov Vladislav <trifonov@ispras.ru> | ||
|
||
RUN apt-get update \ | ||
&& DEBIAN_FRONTEND=noninteractive apt-get install -y locales \ | ||
&& sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen \ | ||
&& dpkg-reconfigure --frontend=noninteractive locales \ | ||
&& update-locale LANG=en_US.UTF-8 | ||
ENV LANG en_US.UTF-8 | ||
ENV LANGUAGE en_US:en | ||
ENV LC_ALL en_US.UTF-8 | ||
|
||
RUN apt-get update && apt-get install -qq -y python3 python3-pip | ||
ENV PYTHONPATH $PYTHONPATH:/derek:/derek/babylondigger:/derek/babylondigger/tdozat-parser-v3 | ||
WORKDIR /derek | ||
COPY requirements.txt . | ||
RUN sed -i "s/tensorflow/tensorflow-gpu/g" requirements.txt | ||
RUN pip3 install -r ./requirements.txt | ||
COPY tools/requirements.txt ./tools/ | ||
RUN pip3 install -r ./tools/requirements.txt | ||
RUN python3 -c "import nltk;nltk.download('punkt')" | ||
|
||
COPY babylondigger ./babylondigger | ||
COPY tools ./tools | ||
COPY derek ./derek |
This file contains 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
This file contains 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