Skip to content

Commit

Permalink
🚀 feat:初始化docker-whistle项目
Browse files Browse the repository at this point in the history
  • Loading branch information
kamalyes committed Mar 16, 2023
0 parents commit 723025e
Show file tree
Hide file tree
Showing 5 changed files with 222 additions and 0 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/build-and-push-to-dockerhub.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: build-and-push-to-dockerhub

on:
release:
types:
- created
# push:
# branches:
# - master
# pull_request:
# branches:
# - master
# workflow_dispatch:

env:
DOCKER_IMAGE: kamalyes/whistle
TAG_NAME: ${{github.ref_name}}

jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: GitHub Tag Name
run: |
echo "Tag name from github.ref_name: ${{env.TAG_NAME}}"
- name: Checkout
uses: actions/checkout@v2
- name: Prepare
id: prepare
run: |
DOCKER_IMAGE=${{env.DOCKER_IMAGE}}
DOCKER_PLATFORMS=linux/amd64,linux/arm64
TAG_NAME=${{env.TAG_NAME}}
DOCKER_IMAGE_TAGS="--tag ${DOCKER_IMAGE}:${TAG_NAME}"
echo ::set-output name=docker_image::${DOCKER_IMAGE}
echo ::set-output name=version::${TAG_NAME}
echo ::set-output name=buildx_args::--platform ${DOCKER_PLATFORMS} \
--build-arg VERSION=${TAG_NAME} \
--build-arg BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') \
--build-arg VCS_REF=${GITHUB_SHA::8} \
${DOCKER_IMAGE_TAGS} .
- name: Set up Docker Buildx
uses: crazy-max/ghaction-docker-buildx@v3
- name: Docker Buildx (build)
run: |
docker buildx build --file Dockerfile --output "type=image,push=false" ${{ steps.prepare.outputs.buildx_args }}
- name: Login to Registry
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_TOKEN }}
- name: Docker Buildx (push)
run: |
docker buildx build --file Dockerfile --output "type=image,push=true" ${{ steps.prepare.outputs.buildx_args }}
55 changes: 55 additions & 0 deletions .github/workflows/build-and-push-to-tencentyun.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: build-and-push-to-tencentyun

on:
release:
types:
- created
# push:
# branches:
# - master
# pull_request:
# branches:
# - master
# workflow_dispatch:

env:
DOCKER_IMAGE: ccr.ccs.tencentyun.com/kamalyes/whistle
TAG_NAME: ${{github.ref_name}}

jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: GitHub Tag Name
run: |
echo "Tag name from github.ref_name: ${{env.TAG_NAME}}"
- name: Checkout
uses: actions/checkout@v2
- name: Prepare
id: prepare
run: |
DOCKER_IMAGE= ${{env.DOCKER_IMAGE}}
TAG_NAME= ${{env.TAG_NAME}}
DOCKER_PLATFORMS=linux/amd64,linux/arm64
DOCKER_IMAGE_TAGS="--tag ${DOCKER_IMAGE}:${TAG_NAME}"
echo ::set-output name=docker_image::${DOCKER_IMAGE}
echo ::set-output name=version::${TAG_NAME}
echo ::set-output name=buildx_args::--platform ${DOCKER_PLATFORMS} \
--build-arg VERSION=${TAG_NAME} \
--build-arg BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') \
--build-arg VCS_REF=${GITHUB_SHA::8} \
${DOCKER_IMAGE_TAGS} .
- name: Set up Docker Buildx
uses: crazy-max/ghaction-docker-buildx@v3
- name: Docker Buildx (build)
run: |
docker buildx build --file Dockerfile --output "type=image,push=false" ${{ steps.prepare.outputs.buildx_args }}
- name: Login to Registry
uses: docker/login-action@v2
with:
registry: ccr.ccs.tencentyun.com
username: ${{ secrets.TENCENTYUN_REGISTRY_USERNAME }}
password: ${{ secrets.TENCENTYUN_REGISTRY_PASSWORD }}
- name: Docker Buildx (push)
run: |
docker buildx build --file Dockerfile --output "type=image,push=true" ${{ steps.prepare.outputs.buildx_args }}
26 changes: 26 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
FROM node:18.15.0-alpine3.17

ENV PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin \
LANG=zh_CN.UTF-8 \
SHELL=/bin/bash

RUN echo -e "https://mirrors.ustc.edu.cn/alpine/v3.17/main\nhttps://mirrors.ustc.edu.cn/alpine/v3.17/community" > /etc/apk/repositories \
&& apk update -f \
&& apk upgrade \
&& apk --no-cache add -f bash \
coreutils \
moreutils \
git \
vim \
wget \
curl \
nano \
tzdata \
perl \
openssl \
ca-certificates \
&& rm -rf /var/cache/apk/* \
&& npm install -g whistle --registry=https://registry.npm.taobao.org

EXPOSE 8899-8929 9006-9026
ENTRYPOINT ["sleep", "36000"]
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Docker版Whistle,不依赖宿主机nodejs版本

# 运行指令

1. 离线Dockerfile部署
```bash
docker build -t kamalyes/whistle:v1.0.0 .
docker run --name whistle -p 8900:8900 -d kamalyes/whistle:v1.0.0
docker exec -it whistle w2 start -p 8900
```

2. dockerHub仓库
```bash
docker-compose -f ./test/docker-compose.yml up -d
docker exec -it whistle w2 start -p 8900
```

# 注意事项
```
若暴漏的端口与宿主机不一致时,许使用宿主机端口
```
66 changes: 66 additions & 0 deletions test/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
version: "3"
services:
whistle:
image: kamalyes/whistle:v1.0.0
container_name: whistle
privileged: true
restart: always
environment:
TZ: Asia/Shanghai
ports:
- 8899:8899
- 8900:8900
- 8901:8901
- 8902:8902
- 8903:8903
- 8904:8904
- 8905:8905
- 8906:8906
- 8907:8907
- 8908:8908
- 8909:8909
- 8910:8910
- 8911:8911
- 8912:8912
- 8913:8913
- 8915:8915
- 8916:8916
- 8917:8917
- 8918:8918
- 8919:8919
- 8920:8920
- 8921:8921
- 8922:8922
- 8923:8923
- 8924:8924
- 8925:8925
- 8926:8926
- 8927:8927
- 8928:8928
- 8929:8929
- 9006:9006
- 9007:9007
- 9008:9008
- 9009:9009
- 9010:9010
- 9011:9011
- 9012:9012
- 9013:9013
- 9015:9015
- 9016:9016
- 9017:9017
- 9018:9018
- 9019:9019
- 9020:9020
- 9021:9021
- 9022:9022
- 9023:9023
- 9024:9024
- 9025:9025
- 9026:9026
networks:
- whistle-network

networks:
whistle-network:
driver: bridge

0 comments on commit 723025e

Please sign in to comment.