forked from mjackson/unpkg
-
Notifications
You must be signed in to change notification settings - Fork 5
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
7 changed files
with
604 additions
and
404 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,108 @@ | ||
name: deploy to docker hub | ||
|
||
on: | ||
push: | ||
tags: | ||
- "v*.*.*" | ||
branches: | ||
- 'master' | ||
|
||
env: | ||
# Use docker.io for Docker Hub if empty | ||
REGISTRY: ${{ secrets.REGISTRY }} | ||
# github.repository as <account>/<repo> | ||
IMAGE_NAME: ${{ github.repository }} | ||
|
||
jobs: | ||
docker-deploy: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- | ||
name: Checkout | ||
uses: actions/checkout@v4 | ||
- uses: pnpm/action-setup@v3 | ||
- | ||
uses: actions/setup-node@v4 | ||
with: | ||
cache: "pnpm" | ||
|
||
- | ||
name: Setup timezone | ||
uses: szenius/set-timezone@v1.2 | ||
with: | ||
timezoneLinux: Asia/Shanghai | ||
|
||
- | ||
name: Install dependencies | ||
run: | | ||
pnpm install | ||
pnpm build | ||
rm -rf tmp | ||
mkdir tmp | ||
cp package.json tmp | ||
cd tmp | ||
npm install --omit dev | ||
pnpm dlx @lzwme/fed-lint-helper rm -f "node_modules/**/{license,LICENSE,README.md,readme.md,.*,*.d.ts,*.flow,*.map}" | ||
# - | ||
# name: Set up QEMU | ||
# uses: docker/setup-qemu-action@v3 | ||
# - | ||
# name: Set up Docker Buildx | ||
# uses: docker/setup-buildx-action@v3 | ||
|
||
- | ||
name: Extract Docker metadata | ||
id: meta | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: ${{ env.IMAGE_NAME }} | ||
tags: | | ||
# set latest tag for default branch | ||
type=raw,value=latest,enable={{is_default_branch}} | ||
# tag event | ||
type=ref,enable=true,priority=600,prefix=,suffix=,event=tag | ||
- | ||
name: Login to Docker Hub | ||
uses: docker/login-action@v3 | ||
with: | ||
# registry: ghcr.io # 声明镜像源 | ||
username: ${{ secrets.DOCKER_USERNAME }} | ||
password: ${{ secrets.DOCKER_PASSWORD }} | ||
- | ||
name: Build and push | ||
id: docker_build | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: . | ||
# platforms: linux/amd64,linux/arm64 | ||
push: ${{ github.event_name != 'pull_request' }} | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
|
||
# - | ||
# name: Login to Docker Hub | ||
# run: | | ||
# docker login --username=${{ secrets.DOCKER_USERNAME }} --password ${{ secrets.DOCKER_PASSWORD }} ${{ env.REGISTRY }} | ||
# - | ||
# name: Build and push Docker Image | ||
# run: | | ||
# docker build -t ${{ env.REGISTRY }}/${{ steps.meta.outputs.tags }} -f Dockerfile . | ||
# docker push ${{ env.REGISTRY }}/${{ steps.meta.outputs.tags }} | ||
|
||
# - | ||
# name: Deploy Docker App | ||
# uses: appleboy/ssh-action@master | ||
# env: | ||
# TZ: Asia/Shanghai | ||
# with: | ||
# host: ${{ secrets.HOST }} | ||
# username: ${{ secrets.HOST_USERNAME }} | ||
# key: ${{ secrets.HOST_SSHKEY }} | ||
# port: ${{ secrets.PORT }} | ||
# script: | | ||
# wget https://raw.githubusercontent.com/${{ env.IMAGE_NAME }}/master/docker/docker-compose.yml | ||
# ls | ||
# cat docker-compose.yml | ||
# docker-compose down -v | ||
# docker-compose up -d |
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 |
---|---|---|
|
@@ -13,3 +13,5 @@ npm-debug.log* | |
/service-account-staging.json | ||
/service-account.json | ||
*.tgz | ||
/tmp | ||
/cache |
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,38 @@ | ||
# FROM node:18-alpine as builder | ||
# COPY package.json .npmrc /tmp/build/ | ||
# RUN set -x \ | ||
# && apk update \ | ||
# && npm i -g pnpm \ | ||
# && cd /tmp/build \ | ||
# && npm install --omit dev \ | ||
# && npx @lzwme/fed-lint-helper rm -f "node_modules/**/{license,LICENSE,README.md,readme.md,.*,*.d.ts,*.flow,*.map}" | ||
|
||
FROM node:18-alpine As producton | ||
LABEL maintainer="renxia <lzwy0820@qq.com>" | ||
|
||
WORKDIR /app | ||
|
||
COPY package.json .npmrc server.js ./ | ||
COPY public public | ||
COPY tmp/node_modules node_modules | ||
|
||
ENV TZ=Asia/Shanghai | ||
# ENV DEBUG=0 | ||
ENV NODE_ENV=production | ||
ENV PORT=8080 | ||
ENV NPM_REGISTRY_URL=https://registry.npmmirror.com | ||
ENV ORIGIN=https://unpkg.com | ||
ENV ENABLE_CLOUDFLARE=0 | ||
ENV CLOUDFLARE_EMAIL='' | ||
ENV CLOUDFLARE_KEY='' | ||
|
||
EXPOSE 8080/tcp | ||
|
||
# RUN npm i -g pnpm --registry $NPM_REGISTRY_URL | ||
# RUN pnpm install --prod --registry $NPM_REGISTRY_URL | ||
|
||
RUN rm -rf /root/.cache \ | ||
&& rm -rf /root/.pnpm-store \ | ||
&& rm -rf /root/.local/share/pnpm/store/v3/files | ||
|
||
ENTRYPOINT [ "node", "server.js"] |
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
Oops, something went wrong.