Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"rules": {
"object-curly-newline": ["error", { "consistent": true }],
"semi": [2, "never"],
"indent": [2, "tab", {
"indent": [8, "space", {
"SwitchCase": 1
}],
"no-tabs": 0
Expand Down
154 changes: 153 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,154 @@
node_modules
dockerfiles
dockerfiles
package-lock.json

# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839

# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf

# AWS User-specific
.idea/**/aws.xml

# Generated files
.idea/**/contentModel.xml

# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml

# Gradle
.idea/**/gradle.xml
.idea/**/libraries

# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/artifacts
# .idea/compiler.xml
# .idea/jarRepositories.xml
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# *.iml
# *.ipr

# CMake
cmake-build-*/

# Mongo Explorer plugin
.idea/**/mongoSettings.xml

# File-based project format
*.iws

# IntelliJ
out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Cursive Clojure plugin
.idea/replstate.xml

# SonarLint plugin
.idea/sonarlint/

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties

# Editor-based Rest Client
.idea/httpRequests

# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser

# ================== FOR MACOS =================

# General
.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon


# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

# ================== FOR WINDOWS =================

# Windows thumbnail cache files
Thumbs.db
Thumbs.db:encryptable
ehthumbs.db
ehthumbs_vista.db

# Dump file
*.stackdump

# Folder config file
[Dd]esktop.ini

# Recycle Bin used on file shares
$RECYCLE.BIN/

# Windows Installer files
*.cab
*.msi
*.msix
*.msm
*.msp

# Windows shortcuts
*.lnk

*~

# ================== FOR LINUX =================

# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*

# KDE directory preferences
.directory

# Linux trash folder which might appear on any partition or disk
.Trash-*

# .nfs files are created when an open file is removed but is still being accessed
.nfs*
8 changes: 8 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions .idea/aliyun-docker-trigger.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 39 additions & 0 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions .idea/codeStyles/codeStyleConfig.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ WORKDIR /app
COPY . .

RUN apk add tzdata --update --no-cache \
&& cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
&& echo "Asia/Shanghai" /etc/localtime \
&& apk del tzdata
&& cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
&& echo "Asia/Shanghai" /etc/localtime \
&& apk del tzdata

RUN apk add docker
RUN apk add docker docker-compose

RUN npm i --production && npm cache clean --force

CMD node .
CMD node .
1 change: 1 addition & 0 deletions config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ module.exports = {
},
subscribers: process.env.EMAIL_SUBSCRIBERS,
},
dockerMode: process.env.DOCKER_MODE | 'swarm',
}
10 changes: 10 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: "3"
services:
aliyun-docker-trigger:
image: registry.cn-hangzhou.aliyuncs.com/your_username/aliyun-docker-trigger:latest
volumes:
- ./dockerfiles:/app/dockerfiles
- /var/run/docker.sock:/var/run/docker.sock
- ~/.docker/config.json:/root/.docker/config.json
ports:
- 8080:80
48 changes: 25 additions & 23 deletions lib/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,34 @@ const DEPLOY_TIME = new Date()
const router = new Router()

router.get('/', async (ctx) => {
ctx.body = [
'[Service]',
`[Deploy] @ ${DEPLOY_TIME}`,
`[Request] @ ${new Date()}`,
`[Version] @ ${json.version}`,
].join('\n')
ctx.response.status = 200
ctx.body = [
'[Service]',
`[Deploy] @ ${DEPLOY_TIME}`,
`[Request] @ ${new Date()}`,
`[Version] @ ${json.version}`,
].join('\n')
ctx.response.status = 200
})

router.post('/', async (ctx) => {
const {
push_data: {
tag,
},
repository:
{
name,
namespace,
region,
},
} = ctx.request.body

await runScript.createOrUpdateContainers(region, namespace, name, tag)
await email.send(name, tag)

ctx.response.status = 200
const {
push_data: {
tag,
},
repository: {
name,
namespace,
region,
},
} = ctx.request.body

// 不等待容器更新完成,但确保 email 在更新后发送
runScript.createOrUpdateContainers(region, namespace, name, tag)
.then(() => email.send(name, tag))
.catch(error => console.error('Error:', error))

// 立即返回响应
ctx.response.status = 200
})

module.exports = router
Loading