-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
94 additions
and
0 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,3 @@ | ||
/cache | ||
/dist | ||
node_modules |
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,39 @@ | ||
name: Build | ||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- main | ||
jobs: | ||
build: | ||
concurrency: | ||
group: build-${{ github.ref }} | ||
cancel-in-progress: true | ||
runs-on: [self-hosted, docker] | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: mr-smithers-excellent/docker-build-push@v5 | ||
name: Build Global & push Docker image | ||
with: | ||
image: kemono/image-optimizer | ||
addLatest: true | ||
registry: registry.ap-northeast-1.aliyuncs.com | ||
dockerfile: deploy/Dockerfile | ||
username: ${{ secrets.DOCKER_USERNAME }} | ||
password: ${{ secrets.DOCKER_PASSWORD }} | ||
|
||
deploy: | ||
needs: [push] | ||
runs-on: [self-hosted, docker] | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Deploy Global | ||
run: | | ||
GIT_HASH=$(git rev-parse --short "$GITHUB_SHA") | ||
cp docker-compose.sample.yml /tmp/docker-compose-${GIT_HASH}.yml | ||
sed -i "s/{{GIT-SHA}}/${GIT_HASH}/g" /tmp/docker-compose.yml | ||
SERVER=("web01" "web02") | ||
parallel "ssh {}.jp.internal.abo.network 'mkdir -p /root/image-optimizer'" ::: "${SERVER[@]}" | ||
parallel scp /tmp/docker-compose-${GIT_HASH}.yml {}.jp.internal.abo.network:/root/image-optimizer/ ::: "${SERVER[@]}" | ||
parallel "ssh {}.jp.internal.abo.network 'cd /root/image-optimizer && docker compose up -d'" ::: "${SERVER[@]}" |
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,33 @@ | ||
# Install dependencies only when needed | ||
FROM node:18-alpine AS deps | ||
RUN apk add --no-cache libc6-compat python3 make g++ bash | ||
WORKDIR /app | ||
COPY package.json yarn.lock* ./ | ||
RUN yarn --frozen-lockfile | ||
|
||
FROM node:18-alpine AS runner-deps | ||
RUN apk add --no-cache libc6-compat python3 make g++ bash | ||
WORKDIR /app | ||
COPY package.json yarn.lock* ./ | ||
RUN yarn --frozen-lockfile --production | ||
|
||
FROM node:18-alpine AS builder | ||
WORKDIR /app | ||
COPY --from=deps /app/node_modules ./node_modules | ||
COPY . ./ | ||
RUN yarn build | ||
|
||
FROM node:18-alpine AS runner | ||
WORKDIR /app | ||
COPY --from=runner-deps /app/node_modules ./node_modules | ||
COPY --from=builder /app/dist ./dist | ||
COPY package.json yarn.lock* ./ | ||
COPY optimizer.config.example.js ./optimizer.config.js | ||
|
||
ENV NODE_ENV production | ||
|
||
EXPOSE 3100 | ||
|
||
ENV PORT 3100 | ||
|
||
CMD ["yarn", "start"] |
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,19 @@ | ||
version: '3' | ||
|
||
services: | ||
kemono-games-search: | ||
image: registry.ap-northeast-1.aliyuncs.com/kemono/image-optimizer:{{GIT-SHA}} | ||
restart: always | ||
deploy: | ||
resources: | ||
limits: | ||
memory: 200M | ||
ports: | ||
- 8150:3000 | ||
extra_hosts: | ||
- 'host.docker.internal:host-gateway' | ||
environment: | ||
- PORT=3000 | ||
volumes: | ||
- ./cache:/app/cache | ||
- ./optimizer.config.js:/app/optimizer.config.js |