-
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* move go.mod to monorepo root * feat(apps/twitch-bot): prepare for the fly.io deployment
- Loading branch information
Showing
7 changed files
with
185 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# flyctl launch added from .gitignore | ||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. | ||
|
||
# dependencies | ||
**/node_modules | ||
**/.pnp | ||
**/.pnp.js | ||
|
||
# testing | ||
**/coverage | ||
|
||
# database | ||
**/prisma/db.sqlite | ||
**/prisma/db.sqlite-journal | ||
|
||
# next.js | ||
**/.next | ||
**/out | ||
|
||
# production | ||
**/build | ||
|
||
# misc | ||
**/.DS_Store | ||
**/*.pem | ||
|
||
# debug | ||
**/npm-debug.log* | ||
**/yarn-debug.log* | ||
**/yarn-error.log* | ||
**/.pnpm-debug.log* | ||
|
||
# local env files | ||
**/.env | ||
**/.env*.local | ||
|
||
# vercel | ||
**/.vercel | ||
|
||
# typescript | ||
**/*.tsbuildinfo | ||
**/pgdata | ||
|
||
**/.turbo | ||
|
||
# flyctl launch added from apps/discord-bot/.gitignore | ||
apps/discord-bot/build | ||
apps/discord-bot/node_modules | ||
apps/discord-bot/**/.env | ||
apps/discord-bot/**/package-lock.json | ||
|
||
# flyctl launch added from packages/senchabot-prisma/.gitignore | ||
packages/senchabot-prisma/**/node_modules | ||
# Keep environment variables out of version control | ||
packages/senchabot-prisma/**/.env | ||
fly.toml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
name: Deploy Twitch Bot | ||
on: | ||
push: | ||
paths: | ||
- apps/twitch-bot/** | ||
branches: | ||
- initial | ||
pull_request: {} | ||
|
||
permissions: | ||
actions: write | ||
contents: read | ||
|
||
jobs: | ||
build: | ||
name: Build | ||
# only build/deploy main branch on pushes | ||
if: ${{ (github.ref == 'refs/heads/initial') && github.event_name == 'push' }} | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Cancel Previous Runs | ||
uses: styfle/[email protected] | ||
|
||
- name: Checkout repo | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
|
||
- name: Cache Docker layers | ||
uses: actions/cache@v3 | ||
with: | ||
path: /tmp/.buildx-cache | ||
key: ${{ runner.os }}-buildx-${{ github.sha }} | ||
restore-keys: | | ||
${{ runner.os }}-buildx- | ||
- name: Fly Registry Auth | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: registry.fly.io | ||
username: x | ||
password: ${{ secrets.TWITCH_BOT_FLY_API }} | ||
|
||
- name: Docker build | ||
uses: docker/build-push-action@v3 | ||
with: | ||
context: . | ||
file: ./apps/twitch-bot/Dockerfile | ||
push: true | ||
tags: registry.fly.io/senchabot0524tw:${{ github.ref_name }}-${{ github.sha }} | ||
build-args: | | ||
COMMIT_SHA=${{ github.sha }} | ||
cache-from: type=local,src=/tmp/.buildx-cache | ||
cache-to: type=local,mode=max,dest=/tmp/.buildx-cache-new | ||
|
||
# This ugly bit is necessary if you don't want your cache to grow forever | ||
# till it hits GitHub's limit of 5GB. | ||
# Temp fix | ||
# https://github.com/docker/build-push-action/issues/252 | ||
# https://github.com/moby/buildkit/issues/1896 | ||
- name: Move cache | ||
run: | | ||
rm -rf /tmp/.buildx-cache | ||
mv /tmp/.buildx-cache-new /tmp/.buildx-cache | ||
deploy: | ||
name: Deploy | ||
runs-on: ubuntu-latest | ||
needs: [build] | ||
# only build/deploy initial branch on pushes | ||
if: ${{ (github.ref == 'refs/heads/initial') && github.event_name == 'push' }} | ||
|
||
steps: | ||
- name: Cancel Previous Runs | ||
uses: styfle/[email protected] | ||
|
||
- name: Checkout repo | ||
uses: actions/checkout@v3 | ||
|
||
- name: Deploy Initial | ||
if: ${{ github.ref == 'refs/heads/initial' }} | ||
uses: superfly/[email protected] | ||
with: | ||
args: "deploy --app senchabot0524tw --image registry.fly.io/senchabot0524tw:${{ github.ref_name }}-${{ github.sha }} --config ./apps/twitch-bot/fly.toml" | ||
env: | ||
FLY_API_TOKEN: ${{ secrets.TWITCH_BOT_FLY_API }} | ||
|
||
# - name: Deploy Production | ||
# if: ${{ github.ref == 'refs/heads/main' }} | ||
# uses: superfly/[email protected] | ||
# with: | ||
# args: "deploy --image registry.fly.io/${{ steps.app_name.outputs.value }}:${{ github.ref_name }}-${{ github.sha }}" | ||
# env: | ||
# FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
FROM golang:1.20-alpine AS builder | ||
|
||
WORKDIR /app | ||
COPY . . | ||
|
||
ARG SERVICE_NAME | ||
|
||
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags "-s -w" -o /app/bin ./apps/twitch-bot/cmd/main/*.go | ||
|
||
FROM scratch AS prod | ||
COPY --from=builder /app/bin bin | ||
|
||
EXPOSE 8080 | ||
|
||
ENTRYPOINT ["./bin"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# fly.toml app configuration file generated for twitchbottest on 2023-07-02T22:29:27+03:00 | ||
# | ||
# See https://fly.io/docs/reference/configuration/ for information about how to use this file. | ||
# | ||
|
||
app = "senchabot0524tw" | ||
primary_region = "ams" | ||
|
||
[http_service] | ||
internal_port = 8080 | ||
force_https = true | ||
auto_stop_machines = false | ||
auto_start_machines = false | ||
min_machines_running = 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
module github.com/senchabot-dev/monorepo/apps/twitch-bot | ||
module github.com/senchabot-dev/monorepo | ||
|
||
go 1.19 | ||
|
||
|
File renamed without changes.