Skip to content

Commit

Permalink
docker-2
Browse files Browse the repository at this point in the history
  • Loading branch information
Baykanurov committed Oct 23, 2023
1 parent 923a094 commit 16a8993
Show file tree
Hide file tree
Showing 12 changed files with 164 additions and 0 deletions.
18 changes: 18 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Выполнено ДЗ №

- [ ] Основное ДЗ
- [ ] Задание со *

## В процессе сделано:
- Пункт 1
- Пункт 2

## Как запустить проект:
- Например, запустить команду X в директории Y

## Как проверить работоспособность:
- Например, перейти по ссылке http://localhost:8080

## PR checklist
- [ ] Выставил label с номером домашнего задания
- [ ] Выставил label с темой домашнего задания
6 changes: 6 additions & 0 deletions .github/auto_assign.yml
Original file line number Diff line number Diff line change
@@ -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
10 changes: 10 additions & 0 deletions .github/workflows/auto-assign.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: 'Auto Assign'
on: pull_request

jobs:
add-reviews:
runs-on: ubuntu-latest
steps:
- uses: kentaro-m/[email protected]
with:
repo-token: '${{ secrets.GITHUB_TOKEN }}'
26 changes: 26 additions & 0 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
@@ -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
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.idea/
poetry.lock
pyproject.toml
packer/variables.json
*.tfstate
*.tfstate.*.backup
*.tfstate.backup
*.tfvars
.terraform/
*.retry
**/roles/jdauphantnginx/*
jdauphant.nginx
6 changes: 6 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -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
43 changes: 43 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
```
15 changes: 15 additions & 0 deletions docker-monolith/Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
1 change: 1 addition & 0 deletions docker-monolith/db_config
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DATABASE_URL=127.0.0.1
4 changes: 4 additions & 0 deletions docker-monolith/docker-1.log
Original file line number Diff line number Diff line change
@@ -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
16 changes: 16 additions & 0 deletions docker-monolith/mongod.conf
Original file line number Diff line number Diff line change
@@ -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
7 changes: 7 additions & 0 deletions docker-monolith/start.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 16a8993

Please sign in to comment.