Sourcetreeを使いたい

source treeを使うには、まずatlassianのサイトからdownloadします
https://www.atlassian.com/ja/software/sourcetree

– SourceTreeのセットアップ
– SourceTreeを使う

$ cd project
$ ls
index.php
$ git init
$ git add .
$ git commit -m “first commit”
$ git remote add origin https://github.com/hpscript/sourcetree.git
$ git push -u origin master

なるほど、git tree上でgit操作をGUI交えて操作できるのね。大体理解した。

[git] hotfix

git hotfixとは?
– リリースされたバージョンで発生したバグを速やかに修正するブランチ
– 修正後すぐmaster, developブランチにマージ

なるほど、そういうことか、特別な機能があるわけではなく、そういう名称で運用するって取り決めのことね。理解した。

[git] branchのマージ

$ ls
program.txt
$ git branch
* master

// ブランチの作成
$ git branch develop
// ブランチの切り替え
$ git checkout develop

// developブランチで開発
$ cat program.txt
9104 商船三井
9107 川崎汽船
// commit
$ git add .
$ git commit -m “develop first commit”

// masterにブランチの切り替え
$ git checkout master
// masterにブランチのマージ
$ git merge develop
$ cat program.txt
9104 商船三井
9107 川崎汽船

$ git branch
develop
* master

「Automatically delete head branches」にチェックを入れておくと、pull requestがmergeされたときにブランチが消える。そうでなければ、branchはそのまま残る。

なるほど、 やってみないとわからんねこれ。

githubのレポジトリをCodeCommitに複製する

$ aws –version
aws-cli/1.22.64 Python/3.8.10 Linux/5.4.0-109-generic botocore/1.24.9
$ git –version
git version 2.25.1

$ git init
$ git add .
$ git commit -m “first commit”
$ git remote add origin https://github.com/hpscript/cicd.git
$ git push -u origin master

### CodeCommit作成
$ GITHUB_ACCOUNT=hogehoge
$ REPO_NAME=fuga
$ GITHUB_REPO_URL=https://github.com/${GITHUB_ACCOUNT}/${REPO_NAME}.git

$ aws codecommit create-repository –repository-name ${REPO_NAME}

### 複製先のRepository情報を定義
$ CODECOMMIT_REGION=ap-northeast-1
$ CODECOMMIT_REPO_URL=https://git-codecommit.${CODECOMMIT_REGION}.amazonaws.com/v1/repos/${REPO_NAME}

### 認証情報ヘルパーの設定
$ git config –global credential.helper ‘!aws codecommit credential-helper $@’
$ git config –global credential.UseHttpPath true

### CodeCommitのRepositoryにpush
$ git push ${CODECOMMIT_REPO_URL} –all

なるほどー

[Docker] flaskのアプリを作る

$ sudo docker container run –name base -it -p 8080:80 python:3.7.5-slim bash
# pip install flask==1.1.1

server.py

import flask
app = flask.Flask('app server')

@app.route('/')
def index():
	return 'Hello docker'

app.run(debug=True, host='0.0.0.0', port=80)

$ sudo docker container cp server.py base:/
# python server.py
Traceback (most recent call last):
File “server.py”, line 1, in
import os, flask
File “/usr/local/lib/python3.7/site-packages/flask/__init__.py”, line 14, in
from jinja2 import escape
ImportError: cannot import name ‘escape’ from ‘jinja2’ (/usr/local/lib/python3.7/site-packages/jinja2/__init__.py)

### コンテナからファイルを転送
$ sudo docker container cp base:/etc/hosts ./
$ cat hosts
127.0.0.1 localhost
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
172.17.0.2 300da009fa4e

### コンテナのイメージ化
$ sudo docker commit base c2img1_app
$ sudo docker images;
REPOSITORY TAG IMAGE ID CREATED SIZE
c2img1_app latest 37a4ea8b1a13 5 seconds ago 189MB
$ sudo docker run –rm -p 8080:80 c2img1_app python -u /server.py
$ sudo docker image history c2img1_app

### imageをpush
$ sudo docker image tag c2img1_app ddddocker/c2img1_app:v1.0
$ sudo docker login
$ sudo docker push ddddocker/c2img1_app:v1.0

なんかやべえな…