diff --git a/.drone.yml b/.drone.yml deleted file mode 100644 index 8cce55e..0000000 --- a/.drone.yml +++ /dev/null @@ -1,29 +0,0 @@ -# yaml-language-server: $schema=https://json.schemastore.org/drone.json -name: deploy -kind: pipeline -type: docker -node: - instance: system -trigger: - event: - - push - branch: - - main -steps: - - name: deploy - image: docker:23.0.6-cli-alpine3.17@sha256:53221a6781b9360dc2965112998cfd209034f2b8cdf98bdc314dfd740bb3c845 - commands: - - mkdir -p /root/.ssh - - install -v -m 600 /home/ubuntu/.ssh/id_ed25519 /root/.ssh/id_ed25519 - - ssh-keyscan beta.fogtype.com >> /root/.ssh/known_hosts - - docker context create --docker=host=ssh://ubuntu@beta.fogtype.com beta - - docker context use beta - - docker compose --project-name=beta up --build --detach - - docker compose --project-directory=example up --detach - volumes: - - name: ssh_key - path: /home/ubuntu/.ssh/id_ed25519 -volumes: - - name: ssh_key - host: - path: /home/ubuntu/.ssh/id_ed25519 diff --git a/.forgejo/workflows/deploy.yml b/.forgejo/workflows/deploy.yml new file mode 100644 index 0000000..f22437f --- /dev/null +++ b/.forgejo/workflows/deploy.yml @@ -0,0 +1,19 @@ +# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json +name: deploy +on: + push: + branches: + - main +jobs: + main: + runs-on: self-hosted + steps: + - run: install -m 700 -d ~/.ssh + - run: install -m 600 <(echo '${{ secrets.KNOWN_HOSTS }}') ~/.ssh/known_hosts + - # "error in libcrypto" になるので CR を除去して回避 + run: install -m 600 <(echo '${{ secrets.DEPLOY_KEY }}' | tr -d '\r') ~/.ssh/id_ed25519 + - run: apk add nodejs + - uses: actions/checkout@v3 + - run: apk add make docker-cli-compose + - run: make setup + - run: make deploy diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..832c775 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.deploy_key +.deploy_key.pub diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..30abf59 --- /dev/null +++ b/Makefile @@ -0,0 +1,13 @@ +.PHONY: setup +setup: + docker context create --docker=host=ssh://ubuntu@beta.fogtype.com beta + +.PHONY: deploy +deploy: export DOCKER_CONTEXT := beta +deploy: + docker compose up --detach --remove-orphans --build + +.deploy_key: + ssh-keygen -t ed25519 -f .deploy_key + ssh-copy-id -i .deploy_key.pub ubuntu@beta.fogtype.com + ssh-keyscan -t ed25519 -H beta.fogtype.com diff --git a/README.md b/README.md index ec9054b..375ea25 100644 --- a/README.md +++ b/README.md @@ -30,3 +30,15 @@ ansible-playbook setup.yml ``` 詳しい構成は [setup.yml](setup.yml) を参照 + +## Registration + +``` +$ make .deploy_key +``` + +secrets.KNOWN_HOSTS +: SSH known_hosts file + +secrets.DEPLOY_KEY +: SSH identity file diff --git a/compose.yml b/compose.yml index 786d4f3..79a3af8 100644 --- a/compose.yml +++ b/compose.yml @@ -1,3 +1,4 @@ +name: beta services: caddy: image: git.fogtype.com/nebel/caddy-docker-proxy