LoginSignup
0
0

More than 1 year has passed since last update.

wsl2上でSD-in-a-Boxを使ってローカルでScrewdriverを実行を試す

Last updated at Posted at 2023-04-29

目的

ただ試したいだけ

参考資料

手順補足

これをもとに進めた。

wsl2を導入する

wsl2のダウンロード先を探すのに苦労した

手順 4 - Linux カーネル更新プログラム パッケージをダウンロードする
最新のパッケージをダウンロードします。
x64 マシン用 WSL2 Linux カーネル更新プログラム パッケージ << これをクリックするとできる。

wsl2のメモリMAXを設定しておく

C:\Users<yourUserName>\に.wslconfigファイルを作成し

[wsl2]
memory=4GB

この設定でもメモリがほとんど消えてる

Docker Destktopを導入する

ここからwindows版をdownloadする。wslを使うからといってlinux版ではない。
今後自動起動してリソースが奪われるので注意すること。PCのメモリは16GB積んでおこう
なぜか自動的にwslと連携している>”64 マシン用 WSL2 Linux カーネル更新プログラム パッケージ” のおかげだと思う

pythonアップデート

pythonを最新版にアップデートしておく

screwdriverインストール

wslで実行する。powershellでは動かない

python <(curl -L https://git.io/sd-in-a-box)

pythonはなかったので、python3で実行している。途中以下の入力が必要

  • Which SCM provider would you like to use? (github/gitlab/bitbucket)
    • github でOK
  • Client ID
    • githubの画面で生成する必要がある。後述する
  • Client Secret
    • githubの画面で生成する必要がある。後述する
$ python3 <(curl -L https://git.io/sd-in-a-box)
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100  9392  100  9392    0     0   7852      0  0:00:01  0:00:01 --:--:--  7852
🎁   Boxing up Screwdriver
👀   Checking prerequisites
🔐   Generating signing secrets
📤   Which SCM provider would you like to use? (github/gitlab/bitbucket) github # koko
📦   Generating OAuth credentials

    Please create a new OAuth application on GitHub.com
    Go to https://github.com/settings/applications/new to start the process
    For 'Homepage URL' put http://172.21.37.64:9000
    For 'Authorization callback URL' put http://172.21.37.64:9001/v4/auth/login

    When done, please provide the following values:

    Client ID: # XXXXX 入力が必要
    Client Secret:  # 見えないだけで入力されている

💾   Writing Docker Compose file
🚀   Screwdriver is ready to launch!

    Just run the following commands to get started!
      $ docker-compose pull
      $ docker-compose -p screwdriver up -d
      $ open http://172.21.37.64:9000

    Would you like to run them now? (y/n) y
[+] Running 3/3
 ✔ ui Pulled                                                                                                                                                                   4.9s 
 ✔ store Pulled                                                                                                                                                                4.0s 
 ✔ api Pulled                                                                                                                                                                  3.4s 
[+] Running 3/3
 ✔ Container screwdriver-store-1  Started                                                                                                                                      3.5s 
 ✔ Container screwdriver-api-1    Started                                                                                                                                      3.6s 
 ✔ Container screwdriver-ui-1     Running                                                                                                                                      0.0s 

👍   Launched!

    A few more things to note:
      - To stop/reset Screwdriver
        $ docker-compose -p screwdriver down
      - If your internal IP changes, update the docker-compose.yml and your SCM OAuth application
      - In-a-box does not support Webhooks including PullRequests for triggering builds
      - To create your own cluster, see https://docs.screwdriver.cd/cluster-management/kubernetes
      - For help with this and more, find us on Slack at https://slack.screwdriver.cd

❤️   Screwdriver Crew

open http://172.21.37.64:9000 はopenコマンドがないのでうごかない。なので自分でブラウザを開く

Client IDとClient Secretの準備

ユーザはgithubとの認証で管理しているらしい。なので認証情報がいる

    Please create a new OAuth application on GitHub.com
    Go to https://github.com/settings/applications/new to start the process
    For 'Homepage URL' put http://172.21.37.64:9000
    For 'Authorization callback URL' put http://172.21.37.64:9001/v4/auth/login

インストール中のメッセージに従い作成する
https://github.com/settings/applications/new

  • Application name は何でもOK
  • 'Homepage URL' 'Authorization callback URL' はメッセージにある通りに設定する。
  • 作ったアプリケーション名の確認画面でClient ID が見れる。Client secretsはgenerate a new client secretで作成できる。

メモリ調整

メモリが足りないと思ったら、mem_limit: 500mを入れておく。

docker-compose.yml
version: '2'
services:
    api:
        image: screwdrivercd/screwdriver:stable
~~~~
        mem_limit: 500m
    ui:
        image: screwdrivercd/ui:stable
~~~~
        mem_limit: 500m

    store:
        image: screwdrivercd/store:stable
~~~~
        mem_limit: 500m

起動停止コマンド

インストールすると起動までしてくれる。その後は以下のコマンドで制御

# 起動
docker-compose -p screwdriver up -d

# 停止
docker-compose -p screwdriver down

wslのIPが変わる

  • 再起動するとIPが変わるらしい。その場合、設定ファイルの修正がいる。wslの再起動はPC再起動以外でいつするのか謎。
vi docker-compose.yml

%s/old_ip/new_ip/gで置換してしまおう

  • githubでつくったアプリのIP設定も直す
    'Homepage URL' 'Authorization callback URL'

  • UIのURL

http://new_ip:9000

IPは変わったら変える。wslのipは以下でわかる。他にもいろいろ方法はある。


$ ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.29.23.249  netmask 255.255.240.0  broadcast 172.29.31.255

やり直したい場合

dataディレクトリとdocker-compose.ymlをmvしてあげれば最初から再実行できる。困ったらこうしよう。

mv data data_bk
mv docker-compose.yml docker-compose.yml.bk
python3 <(curl -L https://git.io/sd-in-a-box)

動作確認

適当にリポジトリをつくり、以下のファイルを作成し、パイプラインと連携させてスタートする。初回実行はイメージがないというエラーが出ているが無視して再実行すればいいのかもしれない

image.png

OSイメージを変えたい

https://hub.docker.com/_/buildpack-deps # このOSはwslな模様

変えるとsd-setup-scmステップで20:11:10 sh: git: command not foundがないというエラーになる。変えられない。これのpreはできんのか?無理。screwdriverでつかうイメージにはgitいれておかないと積むということか。一旦諦める

$ docker pull centos:centos7
$ docker pull rockylinux:8.7

pullするとdocker desktopの画面にも出てくる
https://qiita.com/gahoh/items/7b21377b5c9e3ffddf4a

docker run -it --name="centos7f" centos:centos7 /bin/bash
docker run -it --name="rocky8.7f" rockylinux:8.7 /bin/bash
docker run -it --name="buildpack-deps.7f" buildpack-deps:latest /bin/bash

終わってからきずいたが

https://docs.docker.jp/docker-for-windows/wsl.html#wsl-download
これを読めばよかったのかも

sdコマンド作成

実行したらうまくいった

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0