githubのworkflowsを

2024.03.05

Logging

おはようございます、個人用に初めてgithubのAction用のymlを作ったって話です。githubで個人でactionを使う場合、公開設定、非公開設定ともに使えるようですね、使えないみたいな記述の記事を見かけましたが…。因みに静的解析ツールは導入していません。PHPStanみたいなものは導入していません。仕事では静的解析ツールも導入していますが個人で今回のように雛🐣レベルの開発には必要ないかなって。後々、追加するかもしれませんが?

black flat screen computer monitor
Photo by Markus Winkler on Pexels.com

自分が作ったYmlファイルはこちらでも公開しときますね。actionが成功するまでにかなりの失敗(エラー)を繰り返しましたところが(泣)ですね~。一回では上手く動作してくれず試行錯誤しました良い学びにはなりましたが👍。

name: testing

on:
  push:
    branches: [ "main" ]
  pull_request:
    branches: [ "main" ]
defaults:
  run:
    working-directory: ./turi-map-app
jobs:
  laravel-test:
    runs-on: ubuntu-latest
    services:
      mysql:
        image: mysql:5.7
        ports:
          - 3306:3306
        env:
          MYSQL_ROOT_PASSWORD: turi
          MYSQL_DATABASE: turi
          MYSQL_USER: turi
          MYSQL_PASSWORD: turi
          MYSQL_ALLOW_EMPTY_PASSWORD: 'yes'
        options: --health-cmd "mysqladmin ping -h 127.0.0.1" --health-interval 20s --health-timeout 10s --health-retries 10
    strategy:
      matrix:
        node-version: [21.x]
    steps:
    - uses: shivammathur/setup-php@15c43e89cdef867065b0213be354c2841860869e
      with:
        php-version: '8.2'
        extensions: mbstring, dom, fileinfo, pdo_mysql, PDO, zip
    - uses: actions/checkout@v4
    - name: Copy .env
      run: php -r "file_exists('.env') || copy('.env.testing', '.env');"
    - name: Install Dependencies
      run: composer install -n --prefer-dist
    - name: Generate key
      run: php artisan key:generate
    - name: storage link
      run: php artisan storage:link
    - name: Directory Permissions
      run: chmod -R 777 storage bootstrap/cache
    - name: Use Node.js ${{ matrix.node-version }}
      uses: actions/setup-node@v4
      with:
        node-version: ${{ matrix.node-version }}
    - name: npm install
      run: npm i
    - name: Build Assets
      run: npm run build
    - name: migrate
      run: php artisan migrate
    - name: Execute tests (Unit and Feature tests) via PHPUnit
      run: php artisan test

明日へ続く。

タグ

actions, chmod, defaults, dom, env, extensions, generate, health-cmd, health-timeout, matrix, migrate, MYSQL, password, PDO, ports, services, steps, strategy, Testing, working-directory,

docker参考書では教えてくれないymlの設定🙄。 #docker

2022.12.20

Logging

おはようございます、勉強しているのですが自信がない…。

Dockerをどっか~ん、はいスミマセンおじさんギャグです🙇。ヤムルファイルとDockerファイルを使うと結構手抜きが出来るですね。この頃、Dockerの良いところを取り入れたサービスが新たに登場しましたよね。Finchとか言う奴です・・・AWSが提供しているやつ🙄。

自分は当分、Dockerを使います。Dockerを使用していた前はVirtualBoxでした。他にもVagrant(ベイグラント)に浮気したこともありますが、Dockerを使用してからは他の仮想サービスより使いやすい事が分かりました。使っている人が多いとヤムルファイルやDockerファイルもネットにゴロゴロ転がっていますからね。

さて、最後に自分が使っているymlファイルの設定です、いらない部分もあるかもですがご自由にご使用ください。

    build:
      context: .
      dockerfile: Dockerfile
version: "3"
services:
  web:
    image: almalinux:latest
    container_name: test_v0
    restart: always
    ports:
      - 443:443
      - 80:80
    privileged: true
    command: /sbin/init
    extra_hosts:
      - "taoka-test.com:127.0.0.1"
    volumes:
      - X:/var/www/html:/var/www/html
    build:
      context: .
      dockerfile: Dockerfile
  mysqldb:
      image: mysql:latest
      container_name: test_db_v0
      command: --default-authentication-plugin=mysql_native_password
      restart: always
      hostname: testdbhost1
      environment:
        MYSQL_USER: hogeuser
        MYSQL_PASSWORD: password
        MYSQL_DATABASE: hoge_db
        MYSQL_ROOT_PASSWORD: password
        TZ: "Asia/Tokyo"
      ports:
        - 3306:3306
      expose:
        - '3306'
      volumes:
        - X:/var/test/db/mysql_init:/docker-entrypoint-initdb.d
        - X:/var/test/db/mysql_data:/var/lib/mysql
      tty: true
  postgresdb:
      image: postgres:latest
      container_name: test_postdb_v0
      restart: always
      hostname: testdbhost2
      environment:
        POSTGRES_USER: hogeuser
        POSTGRES_PASSWORD: password
        PGPASSWORD: password
        POSTGRES_DB: hoge_db
        TZ: "Asia/Tokyo"
      ports:
        - 5432:5432
      expose:
        - '5432'
      volumes:
        - X:/var/test/db2/postgres_init:/docker-entrypoint-initdb.d
        - X:/var/test/db2/postgres_data:/var/lib/postgresql/data
      tty: true

タグ

-Command, context, default-authentication-plugin, docker, Environment, expose, Finch, hostname, init, latest, MYSQL, password, ports, postgres, postgresql, sbin, services, tty, Vagrant, virtualBOX,

dockerにmysqlサーバーを追加するYML(ヤムル)ファイル #yml

2022.12.16

Logging

おはようございます、1,2,3🎉。Docker呟き第3回ぐらいですかね🙄。

今日はdockerにmysqlサーバーの設定、追加した話です。これでローカル環境で動作するだろうと思います、実際、mysqlのコマンドをwebサーバーから叩いてみて確認は行っています。尚、webサーバー側にmysqlにインストールして上げないとコマンドでの確認が取れません。

また、Dockerの外側と言えば良いのかな?、外部から例えばHeidisqlなので繋ぎたい場合はホストを127.0.0.1にしないと繋げないようです。そこら編も注意してくださませ🙇。

この頃、Dockerを使うようになってまだ日が浅いので右も左も分からないのですが、もっと出来ることを知りたいなと思って本を購入したわけですが、入門書には自分の知りたいことは、最後のページに書いている部分だけでした。立ち読みしていた時点でそれは分かっていたので、凄く悩んで先日、本を購入したのですが、それでも購入してよかったと思います。

version: "3"
services:
  web:
    image: almalinux:latest
    container_name: web_v0
    ports:
      - 80:80
      - 443:443
    privileged: true
    command: /sbin/init
    extra_hosts:
      - "example.com:127.0.0.1"
    volumes:
      - X:\var\www\html:/var/www/html
  db:
      image: mysql:latest
      container_name: db_v0
      command: --default-authentication-plugin=mysql_native_password
      restart: always
      hostname: mysqlhost
      environment:
        MYSQL_USER: hogeuser
        MYSQL_PASSWORD: password
        MYSQL_DATABASE: hoge_db
        MYSQL_ROOT_PASSWORD: password
      ports:
        - 3306:3306
      expose:
        - '3306'
      volumes:
        - ./db/mysql_init:/docker-entrypoint-initdb.d
        - ./db/mysql_data:/var/lib/mysql
      tty: true

タグ

--privileged, -Command, almalinux, default-authentication-plugin, docker, Environment, example.com, expose, hostname, init, latest, MYSQL, password, ports, restart, sbin, services, tty, volumes,

dockerでlaravel環境構築したお話。 #hosts

2022.12.08

Logging

おはようございます、今日は早朝に明日の記事を書いています😆。

さて、dockerでlaravel環境構築したお話を書いていきます、Dockerの環境でApacheをインストールし、バーチャルホストを設定してwindows側のhostsも変更しDocker側のhostsも設定、起動確認も取れたので、一旦Dockerを終了し再度立ち上げるとDocker側のhostsが初期値に戻っている🤔。

これDockerの仕様らしいので、下記のようにdocker-compose.ymlを設定(extra_hosts)するか、Docker runでコンテナを立ち上げる場合はパラメーター–add-hostを付与してあげないといけない😳。

version: "3"
services:
  web:
    image: almalinux:latest
    container_name: Apache_v2.4
    ports:
      - 80:80
    privileged: true
    command: /sbin/init
    extra_hosts:
      - "example1.com:127.0.0.1"
      - "example2.com:127.0.0.1"
    volumes:
      - E:\var\www\html:/var/www/html
docker run --add-host=example1.com:127.0.0.1 .....

尚、Docker側のhostsを変更しないまま、立ち上げてもLaravelは動かないと思います。何故、動かないかはここでは割愛させて頂きます🙇。

タグ

--add-host, , almalinux, ap, Apache, container, docker, docker-compose, extra, hosts, image, Laravel, latest, name, quot, run, services, Version, web, Windows, yml, インストール, お話, これ, こんてな, バーチャル, パラメーター, ホスト, 一旦, 下記, 今日, 仕様, 付与, , 再度, 初期, 場合, 変更, 早朝, 明日, 構築, 環境, 確認, 終了, 記事, 設定, 起動,