From 16a89932f5aafe21912aa51482f164b4e81b04aa Mon Sep 17 00:00:00 2001 From: Baykanurov Date: Tue, 24 Oct 2023 00:33:18 +0400 Subject: [PATCH] docker-2 --- .github/PULL_REQUEST_TEMPLATE.md | 18 +++++++++++++ .github/auto_assign.yml | 6 +++++ .github/workflows/auto-assign.yml | 10 +++++++ .github/workflows/run-tests.yml | 26 +++++++++++++++++++ .gitignore | 12 +++++++++ .pre-commit-config.yaml | 6 +++++ README.md | 43 +++++++++++++++++++++++++++++++ docker-monolith/Dockerfile | 15 +++++++++++ docker-monolith/db_config | 1 + docker-monolith/docker-1.log | 4 +++ docker-monolith/mongod.conf | 16 ++++++++++++ docker-monolith/start.sh | 7 +++++ 12 files changed, 164 insertions(+) create mode 100644 .github/PULL_REQUEST_TEMPLATE.md create mode 100644 .github/auto_assign.yml create mode 100644 .github/workflows/auto-assign.yml create mode 100644 .github/workflows/run-tests.yml create mode 100644 .gitignore create mode 100644 .pre-commit-config.yaml create mode 100644 docker-monolith/Dockerfile create mode 100644 docker-monolith/db_config create mode 100644 docker-monolith/docker-1.log create mode 100644 docker-monolith/mongod.conf create mode 100644 docker-monolith/start.sh diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..b120338 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,18 @@ +# Выполнено ДЗ № + + - [ ] Основное ДЗ + - [ ] Задание со * + +## В процессе сделано: + - Пункт 1 + - Пункт 2 + +## Как запустить проект: + - Например, запустить команду X в директории Y + +## Как проверить работоспособность: + - Например, перейти по ссылке http://localhost:8080 + +## PR checklist + - [ ] Выставил label с номером домашнего задания + - [ ] Выставил label с темой домашнего задания diff --git a/.github/auto_assign.yml b/.github/auto_assign.yml new file mode 100644 index 0000000..fcd38ec --- /dev/null +++ b/.github/auto_assign.yml @@ -0,0 +1,6 @@ +# Set to true to add assignees to pull requests +addAssignees: true + +# A list of reviewers to be added to pull requests (GitHub user name) +reviewers: + - mrgreyves diff --git a/.github/workflows/auto-assign.yml b/.github/workflows/auto-assign.yml new file mode 100644 index 0000000..7ac2755 --- /dev/null +++ b/.github/workflows/auto-assign.yml @@ -0,0 +1,10 @@ +name: 'Auto Assign' +on: pull_request + +jobs: + add-reviews: + runs-on: ubuntu-latest + steps: + - uses: kentaro-m/auto-assign-action@v1.2.4 + with: + repo-token: '${{ secrets.GITHUB_TOKEN }}' diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml new file mode 100644 index 0000000..854adf2 --- /dev/null +++ b/.github/workflows/run-tests.yml @@ -0,0 +1,26 @@ +name: Run tests for OTUS homework + +on: + push: + branches-ignore: main + pull_request: + branches-ignore: main + +jobs: + test: + runs-on: ubuntu-latest + + steps: + - name: Checkout this repo + uses: actions/checkout@v2 + with: + ref: ${{ github.ref }} + - name: Checkout repo with tests + uses: actions/checkout@v2 + with: + repository: "express42/otus-homeworks" + ref: 2023-03 + path: "./otus-homeworks/" + + - name: Run tests + run: curl https://raw.githubusercontent.com/express42/otus-homeworks/2023-03/run.sh | bash diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a68b3d1 --- /dev/null +++ b/.gitignore @@ -0,0 +1,12 @@ +.idea/ +poetry.lock +pyproject.toml +packer/variables.json +*.tfstate +*.tfstate.*.backup +*.tfstate.backup +*.tfvars +.terraform/ +*.retry +**/roles/jdauphantnginx/* +jdauphant.nginx diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..feb9c39 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,6 @@ +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v2.3.0 + hooks: + - id: end-of-file-fixer + - id: trailing-whitespace diff --git a/README.md b/README.md index bae14f2..ccb0259 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,45 @@ # Baykanurov_microservices Baykanurov microservices repository + +## Docker-2 +### Что было сделано: +1. Установка Docker (уже был Docker Desktop, работаю на WSL2) +2. Выполнено знакомство с основными командами Docker +3. Результат команды `docker images` был сохранен в `docker-monolith/docker-1.log` +4. Yandex Cloud CLI был установлен раннее +5. Установка Docker machine v0.16.2 +```shell +sudo curl -o /usr/local/bin/docker-machine -L https://github.com/docker/machine/releases/download/v0.16.2/docker-machine-`uname -s`-`uname -m` && \ +sudo chmod +x /usr/local/bin/docker-machine +``` +6. Создан инстанс +```shell +yc compute instance create \ + --name docker-host \ + --zone ru-central1-a \ + --network-interface subnet-name=default-ru-central1-a,nat-ip-version=ipv4 \ + --create-boot-disk image-folder-id=standard-images,image-family=ubuntu-2004-lts,size=15 --preemptible --cores=2 \ + --ssh-key ~/.ssh/id_ed25519.pub +``` +7. Инициализировано окружение Docker +```shell +docker-machine --debug create \ + --driver generic \ + --generic-ip-address=51.250.84.88 \ + --generic-ssh-user yc-user \ + --generic-ssh-key ~/.ssh/id_ed25519 \ + docker-host +``` +8. Активируем окружение Docker +```shell +eval $(docker-machine env docker-host) +``` +9. Собраз образ reddit:latest +10. Отправлен образ в Docker hub +```shell +docker push baykanurov/otus-reddit:1.0 +``` +11. Проверить образ можно командой +```shell +docker pull baykanurov/otus-reddit:1.0 +``` \ No newline at end of file diff --git a/docker-monolith/Dockerfile b/docker-monolith/Dockerfile new file mode 100644 index 0000000..8030eb5 --- /dev/null +++ b/docker-monolith/Dockerfile @@ -0,0 +1,15 @@ +FROM ubuntu:18.04 + +RUN apt-get update +RUN apt-get install -y mongodb-server ruby-full ruby-dev build-essential git +RUN gem install bundler -v 1.16.1 +RUN git clone -b monolith https://github.com/express42/reddit.git + +COPY mongod.conf /etc/mongod.conf +COPY db_config /reddit/db_config +COPY start.sh /start.sh + +RUN cd /reddit && rm Gemfile.lock && bundle install +RUN chmod 0777 /start.sh + +CMD ["/start.sh"] \ No newline at end of file diff --git a/docker-monolith/db_config b/docker-monolith/db_config new file mode 100644 index 0000000..e6b3b3c --- /dev/null +++ b/docker-monolith/db_config @@ -0,0 +1 @@ +DATABASE_URL=127.0.0.1 \ No newline at end of file diff --git a/docker-monolith/docker-1.log b/docker-monolith/docker-1.log new file mode 100644 index 0000000..e323ac2 --- /dev/null +++ b/docker-monolith/docker-1.log @@ -0,0 +1,4 @@ +REPOSITORY TAG IMAGE ID CREATED SIZE +baykanurov/ubuntu-tmp-file latest 759df1901f35 About a minute ago 63.2MB +ubuntu 18.04 f9a80a55f492 4 months ago 63.2MB +hello-world latest 9c7a54a9a43c 5 months ago 13.3kB diff --git a/docker-monolith/mongod.conf b/docker-monolith/mongod.conf new file mode 100644 index 0000000..f530d17 --- /dev/null +++ b/docker-monolith/mongod.conf @@ -0,0 +1,16 @@ +# Where and how to store data. +storage: + dbPath: /var/lib/mongodb + journal: + enabled: true + +# where to write logging data. +systemLog: + destination: file + logAppend: true + path: /var/log/mongodb/mongod.log + +# network interfaces +net: + port: 27017 + bindIp: 127.0.0.1 \ No newline at end of file diff --git a/docker-monolith/start.sh b/docker-monolith/start.sh new file mode 100644 index 0000000..c133c65 --- /dev/null +++ b/docker-monolith/start.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +/usr/bin/mongod --fork --logpath /var/log/mongod.log --config /etc/mongodb.conf + +source /reddit/db_config + +cd /reddit && puma || exit \ No newline at end of file