GitHub ActionsでDocker RegistryにDockerイメージをpushする(latestタグ、GitHub Release連携でバージョン付け)

https://blog.aoirint.com/entry/2021/github_actions_docker_io_token/ 上の記事のWorkflowテンプレートをちょっと改良した。 Docker Hub以外のDockerレジストリに対応 GitHub Release作成時にリリースタグをイメージタグにしてpush レジストリURL Docker Hub: docker.io GitHub Container Registry: ghcr.io GitLab Container Registry: registry.gitlab.com GitHub Secrets DOCKER_USERNAME DOCKER_TOKEN GitHub Workflow .github/workflows/docker.yml https://github.com/docker/login-action https://github.com/docker/build-push-action name: Push to Docker registry on: push: branches: - main release: types: - created env: IMAGE_NAME: docker.io/username/imagename IMAGE_TAG: ${{ github.event.release.tag_name != '' && github.event.release.tag_name || 'latest' }} jobs: push: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - name: Setup Docker Buildx id: buildx uses: docker/setup-buildx-action@v2 - name: Login to Docker Registry uses: docker/login-action@v2 with: registry: docker.io username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_TOKEN }} - name: Build and Deploy Docker image uses: docker/build-push-action@v3 env: IMAGE_NAME_AND_TAG: ${{ format('{0}:{1}', env.IMAGE_NAME, env.IMAGE_TAG) }} with: context: . builder: ${{ steps.buildx.outputs.name }} file: ./Dockerfile push: true tags: ${{ env.IMAGE_NAME_AND_TAG }} cache-from: type=registry,ref=${{ env.IMAGE_NAME_AND_TAG }}-buildcache cache-to: type=registry,ref=${{ env.IMAGE_NAME_AND_TAG }}-buildcache,mode=max

2022年6月24日 · aoirint

pip-compileでMetadataGenerationFailedの例外が起きる

pip-compileは、pip-toolsパッケージ(jazzband/pip-tools)に含まれるコマンドで、 Pythonパッケージのリストrequirements.inから、 依存ツリーのライブラリバージョンリストrequirements.txtを出力してくれる便利なツールである。 入力例 requirements.in django requests gunicorn mysqlclient python-dateutil requests-oauthlib schedule pip-compile requirements.in 出力例 requirements.txt # # This file is autogenerated by pip-compile with python 3.8 # To update, run: # # pip-compile requirements.in # asgiref==3.5.2 # via django backports-zoneinfo==0.2.1 # via django certifi==2022.6.15 # via requests charset-normalizer==2.0.12 # via requests django==4.0.5 # via -r requirements.in gunicorn==20.1.0 # via -r requirements.in idna==3.3 # via requests mysqlclient==2.1.1 # via -r requirements.in oauthlib==3.2.0 # via requests-oauthlib python-dateutil==2.8.2 # via -r requirements.in requests==2.28.0 # via # -r requirements.in # requests-oauthlib requests-oauthlib==1.3.1 # via -r requirements.in schedule==1.1.0 # via -r requirements.in six==1.16.0 # via python-dateutil sqlparse==0.4.2 # via django urllib3==1.26.9 # via requests # The following packages are considered to be unsafe in a requirements file: # setuptools https://pypi.org/project/pip-tools/ (現在 pip-tools==6.6.2) https://github.com/jazzband/pip-tools ところでPythonパッケージは、システムパッケージの事前インストールを要求することがある。 以下、システムパッケージ名はDebian/Ubuntuを想定する。 ...

2022年6月24日 · aoirint

Among Us Modding

modding公式ポリシー: https://www.innersloth.com/among-us-mod-policy/ ReactorのDiscordに解析に使えるDLL(Assembly-CSharp.dll)が投下されている(実装入り) https://qiita.com/Koke1024/items/b22eb842b01399f5694f https://github.com/NuclearPowered/Reactor 実装が不要でインタフェースだけの確認の場合、Il2CppDumperにGameAssembly.dllとglobal-metadata.datをかませて、実装が含まれないAssembly-CSharp.dllを吐き出させることができるので、自前で確認できる(公式アプデ後最速で確認するのに有用) https://github.com/Perfare/Il2CppDumper DLLのデコンパイルには、Assembly-CSharp.dllをdnSpyやILSpyに読ませるとよい https://github.com/dnSpy/dnSpy https://github.com/icsharpcode/ILSpy 処理をインジェクションするためのフレームワーク https://github.com/BepInEx/BepInEx

2022年6月22日 · aoirint

ブログ運用

Gatsby重い 投稿画面ほしい(WebAPIでGit触るのは遅いから嫌) FindyとかにRSSクロールさせているけれど、趣旨に合わない記事を載せたくない 載せたい記事=技術系の記事 新しいアプリケーションをリリースした 技術解説 載せたくない記事=個人的な記事 同人イベント参加してきた 日記 質の低い作業メモ 運用の例 ブログ:趣旨に合う記事だけ投稿する、Twitter:個人的なこと 技術ブログ:載せたい記事だけ投稿する、日常ブログ・Twitter:個人的なこと 記事を書く体力がないことが問題? -それはそう APIのURL一覧とか、参考URL1個載せたら解決する問題とか、そういうメモレベルの記録を残す場所がほしい それはいまScrapbox・Joplin・Evernoteになっている 権利的にpublicにできない個人的な動画クリップとかPDFとかを整理してprivateに残す場所がほしい 小さいサービスを作ってデプロイする頻度を上げたい?? 1つサービスを作るとDBがついてくるから難しいという課題意識がある DBをホストするためにメモリを消費する VPSのメモリ資源は有限 自分1人しか使わないシステムならSQLite3で十分ではないか Postgresは案外軽いかも? 実はDBよりアプリの方がメモリ消費が大きいのではないか DBを作ること自体は簡単でも、未来の保守変更移行が発生する その経験が浅いので、安易にDBを作ることに忌避感がある URLの永続性 エゴサ回避 クソリプ回避 はてなブックマーク、URL付き晒し、スクショ晒しがあるから無理では? こいつここでこんなこと言ってるぜ(=みんなで叩こう)、というやつ 裏アカウントは燃える 画面はReactで作りたい プレビュー モバイル対応 Twitter埋め込み Mastodon埋め込み ニコニコ動画埋め込み YouTube埋め込み OGP埋め込み

2022年6月18日 · aoirint

Let's Encrypt Failure Rate Limit

設定に自信がないときは、Rate limitが緩いLet’s EncryptのStaging環境で試してから本番環境でやり直す Staging環境を使うには、certbotのオプションに --test-cert をつける 本番環境の場合、1時間内に5回失敗すると一時的に弾かれるようになる(too many failed authorizations recently) Staging環境の場合、1時間内に60回失敗まで緩められている 本番環境 https://letsencrypt.org/docs/rate-limits/ Staging環境 https://letsencrypt.org/docs/staging-environment/

2022年6月16日 · aoirint

PGP

https://qiita.com/umi/items/2074aac509a6e78c4ef4 https://gnupg.org/download/ Windowsバイナリ https://gpg4win.org/get-gpg4win.html https://keybase.io/aoirint フィンガープリント: EFA9 05B1 BAB7 B91E DFF0 5A3F 9404 6621 FF11 BC4B 有効期限: 2024-06-11 公開鍵 -----BEGIN PGP PUBLIC KEY BLOCK----- mQGNBGKmWRcBDAD6fBPqQeYf5e5YTLyQQ6loiqFhCAi5DeL67aKbXRb6d7u+13um B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RF9iqPJ4+UBLNc2giwZi ecprBMbyB514QWU+bJ/P0fdULF3ofySW9yxeRxz00sUh4vBXlhadpmrBRLInPFWw CF2HZCE7if9HHxNo12HF21ncFQ== =Wkdz -----END PGP PUBLIC KEY BLOCK-----

2022年6月13日 · aoirint

効果音素材

無料効果音で遊ぼう!(小森平): https://taira-komori.jpn.org/freesound.html DOVA-SYNDROME: https://dova-s.jp/se/ ぷー!: https://dova-s.jp/se/play1226.html 効果音ラボ: https://soundeffect-lab.info/ 声素材: https://soundeffect-lab.info/sound/voice/game.html

2022年6月10日 · aoirint

Use MinIO with AWS CLI

AWS S3互換を意識して、設定にあたってMinIOに依存しすぎないようにしたい (それはそれとしてMinIO ClientはAWS S3互換クライアントとして便利らしい) https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html aws-cli version: 2.7.7 curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" unzip awscliv2.zip sudo ./aws/install https://awscli.amazonaws.com/v2/documentation/api/latest/reference/index.html --endpoint-urlで操作対象をAWS S3からMinIOに変更できる https://awscli.amazonaws.com/v2/documentation/api/latest/topic/config-vars.html AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY AWS以外の認証情報を~/.aws/credentialsに保持するのもいまいちな感があるので、環境変数に設定することにする (AWSのIAM?がどうなってるのかよくわからんけど、本来マニュアルオペレーションするときはAWSのアカウントで認証するのかな?) https://docs.aws.amazon.com/ja_jp/cli/latest/userguide/cli-services-s3-commands.html まずは特権アクセスでBucketを作る MinIOのrootユーザのユーザ名・パスワードを設定する(MINIO_ROOT_USER、MINIO_ROOT_PASSWORD) export AWS_ACCESS_KEY_ID=minioadmin export AWS_SECRET_ACCESS_KEY=minioadmin Bucket一覧 aws --endpoint-url http://127.0.0.1:9000 s3 ls Bucket作成(create-bucketも大して変わらんと思うので、あえて高レベルAPIのs3 mbを使わなくていい気もするけどまあいいでしょう) aws --endpoint-url http://127.0.0.1:9000 s3 mb s3://mybucket アクセス制御(Policy)周りはS3と一部互換性がない Policyの構文自体はほぼ同じに作られているけれど、仕様が違うように思われる(AWS S3の仕様をよく知らんけど) https://github.com/minio/minio/issues/9530#issuecomment-625883667 Bucket policyはパブリックアクセスのルール、User/ServiceAccount Policyは認証付きルールと使い分ければいいと思われる Bucket policyはAWS S3互換APIから設定できる User/ServiceAccount PolicyはAWS互換APIから設定できないのでWeb UIまたはMinIO Clientから設定する Bucket policy: allow anonymous user (public) to read mybucket/* { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": { "AWS": [ "*" ] }, "Action": [ "s3:GetObject" ], "Resource": [ "arn:aws:s3:::mybucket/*" ] } ] } PrincipalはMinIO上のBucketとしては意味がないと思うが、Web Consoleでいじると必要だといわれるので付けておく ...

2022年6月10日 · aoirint

8bitサングラス(Thug life glasses)

https://detail.chiebukuro.yahoo.co.jp/qa/question_detail/q11207037291 https://nico-tube.net/thug-life-glasses/

2022年6月9日 · aoirint

Python subprcess stdout, stderrをキャプチャする

threading https://ja.stackoverflow.com/questions/60539/subprocess-popenのstdoutとstderrをリアルタイムに取得する # python 3.9 import subprocess from threading import Thread def main(): command = [ 'mycommand', '-opt1', ] proc = subprocess.Popen( command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, ) def read_stdout(stdout): for line in stdout: line_text = line.decode('utf-8').strip() print(f'STDOUT: {line_text}', flush=True) print('stdout closed') # closed when process exited def read_stderr(stderr): for line in stderr: line_text = line.decode('utf-8').strip() print(f'STDERR: {line_text}', flush=True) print('stderr closed') # closed when process exited Thread(target=read_stdout, args=(proc.stdout,)).start() Thread(target=read_stderr, args=(proc.stderr,)).start() while True: returncode = proc.poll() if returncode is not None: break time.sleep(0.01) print(f'exited {returncode}') asyncio https://stackoverflow.com/questions/28492103/how-to-combine-python-asyncio-with-threads https://qiita.com/matsui-k20xx/items/4d1c00c4eefd60ba635b import time import asyncio from concurrent.futures import ThreadPoolExecutor async def main(): loop = asyncio.get_event_loop() executor = ThreadPoolExecutor(2) def operation(): time.sleep(1) print('aaa', flush=True) # 2個ずつ実行される(asyncio.runの実行終了まで2秒かかる) loop.run_in_executor(executor, operation) loop.run_in_executor(executor, operation) loop.run_in_executor(executor, operation) loop.run_in_executor(executor, operation) # main関数の実行はブロックされない print('before aaa') asyncio.run(main()) import time import asyncio from asyncio.subprocess import create_subprocess_exec, PIPE from concurrent.futures import ThreadPoolExecutor async def main(): command = [ 'mycommand', '-opt1', ] proc = await create_subprocess_exec( command[0], *command[1:], stdout=PIPE, stderr=PIPE, ) loop = asyncio.get_event_loop() executor = ThreadPoolExecutor() def read_stdout(stdout): while True: line = asyncio.run_coroutine_threadsafe(stdout.readline(), loop).result() if not line: break line_text = line.decode('utf-8').strip() print(f'STDOUT: {line_text}', flush=True) print('stdout closed') # closed when process exited def read_stderr(stderr): while True: line = asyncio.run_coroutine_threadsafe(stderr.readline(), loop).result() if not line: break line_text = line.decode('utf-8').strip() print(f'STDERR: {line_text}', flush=True) print('stderr closed') # closed when process exited loop.run_in_executor(executor, read_stdout, proc.stdout) loop.run_in_executor(executor, read_stderr, proc.stderr) await proc.wait() print(f'exited {proc.returncode}') https://stackoverflow.com/questions/45600579/asyncio-event-loop-is-closed-when-getting-loop 終了時にEvent loop is closedというエラーが出ることがある? ...

2022年6月6日 · aoirint