Skip to content

Commit 8cf8a61

Browse files
committed
gocron2
1 parent 98b6daf commit 8cf8a61

15 files changed

+194
-240
lines changed

.github/workflows/main.yml

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,40 +4,40 @@ jobs:
44
runs-on: ubuntu-latest
55
steps:
66
- id: meta
7-
uses: docker/metadata-action@v3
7+
uses: docker/metadata-action@v5
88
with:
99
images: |
10-
sstc/gocron
10+
sstc/gocron2
1111
tags: |
1212
type=raw,value=latest
13-
type=raw,value=scratch
14-
- uses: docker/setup-qemu-action@v2
15-
- uses: docker/setup-buildx-action@v2
16-
- uses: docker/login-action@v1
13+
type=raw,value=all
14+
- uses: docker/setup-qemu-action@v3
15+
- uses: docker/setup-buildx-action@v3
16+
- uses: docker/login-action@v3
1717
with:
1818
username: ${{ secrets.DOCKERHUB_USERNAME }}
1919
password: ${{ secrets.DOCKERHUB_TOKEN }}
20-
- name: :scratch
21-
uses: docker/build-push-action@v4
20+
- name: :all
21+
uses: docker/build-push-action@v6
2222
with:
2323
push: true
2424
platforms: linux/amd64,linux/arm64
25-
file: ./scratch/Dockerfile
25+
file: ./all/Dockerfile
2626
tags: ${{ steps.meta.outputs.tags }}
27-
- name: :all
28-
uses: docker/build-push-action@v4
27+
- name: :server
28+
uses: docker/build-push-action@v6
2929
with:
3030
push: true
3131
platforms: linux/amd64,linux/arm64
32-
file: ./all/Dockerfile
33-
tags: sstc/gocron:all
34-
- uses: actions/checkout@v2
32+
file: ./server/Dockerfile
33+
tags: sstc/gocron:server
34+
- uses: actions/checkout@v4
3535
- uses: christian-korneck/update-container-description-action@v1
3636
env:
3737
DOCKER_USER: ${{ secrets.DOCKERHUB_USERNAME }}
3838
DOCKER_PASS: ${{ secrets.DOCKERHUB_PASSWORD }}
3939
with:
40-
destination_container_repo: sstc/gocron
40+
destination_container_repo: sstc/gocron2
4141
short_description: https://github.com/${{ github.repository }}
4242
- uses: up9cloud/action-notify@master
4343
if: cancelled() == false

Dockerfile-0

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,19 @@
1-
FROM golang:1.19 as builder
1+
FROM alpine:3.7 AS builder
22

3-
ENV GOCRON_VERSION=1.5.3
4-
ENV GOCRON_SOURCE_DOWNLOAD_URL=https://github.com/ouqiang/gocron/archive/refs/tags/v${GOCRON_VERSION}.tar.gz
5-
ENV GOCRON_DOWNLOAD_URL=https://github.com/ouqiang/gocron/releases/download/v${GOCRON_VERSION}/gocron-node-v${GOCRON_VERSION}-linux-amd64.tar.gz
6-
ENV GOCRON_NODE_DOWNLOAD_URL=https://github.com/ouqiang/gocron/releases/download/v${GOCRON_VERSION}/gocron-v${GOCRON_VERSION}-linux-amd64.tar.gz
3+
ENV GOCRON2_VERSION=1.6.2
4+
ENV GOCRON2_REPO_BASEURL=https://github.com/up9cloud/gocron2
5+
ENV GOCRON2_DOWNLOAD_FILE=gocron2-v${GOCRON2_VERSION}-linux-amd64.tar.gz
6+
ENV GOCRON2_DOWNLOAD_URL=${GOCRON2_REPO_BASEURL}/releases/download/v${GOCRON2_VERSION}/${GOCRON2_DOWNLOAD_FILE}
7+
ENV GOCRON2_NODE_DOWNLOAD_FILE=gocron2-node-v${GOCRON2_VERSION}-linux-amd64.tar.gz
8+
ENV GOCRON2_NODE_DOWNLOAD_URL=${GOCRON2_REPO_BASEURL}/releases/download/v${GOCRON2_VERSION}/${GOCRON2_NODE_DOWNLOAD_FILE}
79
ENV CERTSTRAP_VERSION=1.3.0
810
ENV CERTSTRAP_DOWNLOAD_URL=https://github.com/square/certstrap/releases/download/v${CERTSTRAP_VERSION}/certstrap-linux-amd64
911

1012
WORKDIR /tmp
1113
RUN set -ex; \
12-
apt-get update; \
13-
apt-get install -y \
14-
nodejs npm \
15-
; \
16-
apt-get remove cmdtest; \
17-
npm install -g yarn; \
18-
git clone https://github.com/up9cloud/gocron.git; \
19-
# git checkout tags/v${GOCRON_VERSION}; \
20-
# curl -sSL ${GOCRON_SOURCE_DOWNLOAD_URL} -o gocron.tar.gz; \
21-
# tar -xvf gocron.tar.gz; \
22-
cd gocron
14+
wget ${GOCRON2_DOWNLOAD_URL}; \
15+
tar zvxf ${GOCRON2_DOWNLOAD_FILE}; \
16+
wget ${GOCRON2_NODE_DOWNLOAD_URL}; \
17+
tar zvxf ${GOCRON2_NODE_DOWNLOAD_FILE}; \
18+
wget ${CERTSTRAP_DOWNLOAD_URL} -o certstrap; \
19+
chmod +x certstrap

Dockerfile-1-build

Lines changed: 0 additions & 10 deletions
This file was deleted.

Dockerfile-2-download

Lines changed: 0 additions & 8 deletions
This file was deleted.

Dockerfile-all.template

Lines changed: 31 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,51 @@
1-
${TEMPLATE_0}
2-
${TEMPLATE_1}
3-
${TEMPLATE_2}
1+
${PARTIAL_0}
42

5-
FROM ${ALL_IMAGE}
3+
FROM sstc/headful-chromium:ubuntu-24
64
RUN set -ex; \
7-
apt-get update; \
8-
DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y \
5+
apt update; \
6+
DEBIAN_FRONTEND=noninteractive apt install --no-install-recommends -y \
97
tini \
108
iputils-ping \
119
dnsutils \
1210
rsync \
1311
curl \
1412
jq \
15-
; \
16-
# In the mean time, install all famous script languages
13+
; \
14+
# In the mean time, install all popular scripting languages
1715
curl -fsSL https://deb.nodesource.com/setup_lts.x | bash -; \
18-
DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y \
16+
DEBIAN_FRONTEND=noninteractive apt install --no-install-recommends -y \
17+
nodejs \
18+
npm \
1919
php \
2020
ruby \
21-
lua5.3 \
22-
; \
23-
apt-get clean; \
21+
lua5.4 \
22+
; \
23+
bash --version; \
24+
perl --version; \
25+
python2 --version; \
26+
python3 --version; \
27+
node -v; \
28+
npm -v; \
29+
php -v; \
30+
ruby -v; \
31+
lua -v; \
32+
apt clean; \
2433
rm -rf /var/lib/apt/lists/*
2534

35+
# https://npmtrends.com/axios-vs-got-vs-node-fetch-vs-request-vs-superagent
2636
RUN set -e; \
2737
npm -g install \
2838
node-fetch
2939

30-
ENTRYPOINT ["tini", "--"]
31-
32-
COPY --from=builder /tmp/gocron/bin/gocron /gocron/gocron
33-
COPY --from=builder /tmp/gocron/bin/gocron-node /gocron/gocron-node
34-
COPY --from=builder /tmp/certstrap /gocron/certstrap
35-
COPY gocron-all.sh /gocron/gocron-all.sh
36-
COPY init-cert.sh /gocron/init-cert.sh
40+
WORKDIR /gocron2
41+
COPY --from=builder /tmp/gocron2 /gocron2/gocron2
42+
COPY --from=builder /tmp/gocron2-node /gocron2/gocron2-node
43+
COPY --from=builder /tmp/certstrap /gocron2/certstrap
44+
COPY run-all.sh /gocron2/run-all.sh
45+
COPY init-cert.sh /gocron2/init-cert.sh
3746

38-
WORKDIR /gocron
39-
VOLUME [ "/gocron/conf", "/gocron/log", "/gocron/out" ]
47+
VOLUME [ "/gocron2/conf", "/gocron2/log", "/gocron2/out", "/app" ]
4048
EXPOSE 5920
4149
EXPOSE 5921
42-
CMD ["/gocron/gocron-all.sh"]
50+
ENTRYPOINT ["tini", "--"]
51+
CMD ["/gocron2/run-all.sh"]

Dockerfile-scratch.template

Lines changed: 0 additions & 11 deletions
This file was deleted.

Dockerfile-server.template

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
${PARTIAL_0}
2+
3+
FROM scratch
4+
5+
WORKDIR /gocron2
6+
COPY --from=builder /tmp/gocron2 /gocron2/gocron2
7+
8+
VOLUME [ "/gocron2/conf", "/gocron2/log", "/gocron2/out" ]
9+
EXPOSE 5920
10+
CMD [ "/gocron2/gocron2", "web" ]

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2022 ~ Present https://github.com/up9cloud
3+
Copyright (c) 2024 ~ Present https://github.com/up9cloud
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 47 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,82 +1,79 @@
1-
# docker-gocron
1+
# docker-gocron2
22

33
## Usage
44

5-
> Simple way: gocron and gocron-node in same container
5+
> One container: gocron2 and gocron2-node are in the same container
66
77
```bash
8-
# Step 1: Up
8+
# Up gocron2 and gocron2-node
99
docker run -d --rm \
10-
-v /path/to/conf:/gocron/conf \
11-
-v /path/to/log:/gocron/log \
10+
-v /path/to/conf:/gocron2/conf \
11+
-v /path/to/log:/gocron2/log \
1212
-v /my/task-scripts:/app \
1313
-p 5920:5920 \
14-
sstc/gocron:all
14+
sstc/gocron2
1515

16-
# Step 2: Open 127.0.0.1:5920 to install
16+
# Open 127.0.0.1:5920 to install
1717
```
1818

19-
> Hard ways: gocron and gocron-node are in the different containers, but they're on same host
19+
> One host: gocron2 and gocron2-node are in the different containers, but on the same host
2020
2121
```bash
22-
# Step 1: Up gocron
23-
docker run -d --name gocron \
24-
-v /path/to/conf:/gocron/conf \
25-
-v /path/to/log:/gocron/log \
22+
# Up gocron2
23+
docker run -d --name gocron2 \
24+
-v /path/to/conf:/gocron2/conf \
25+
-v /path/to/log:/gocron2/log \
2626
--net host \
27-
sstc/gocron:latest
27+
sstc/gocron2:server
2828

29-
# Step 2: Open 127.0.0.1:5920 to install
30-
31-
# Step 3: Up gocron-node
32-
docker run -d --name gocron-node \
29+
# Up gocron2-node
30+
docker run -d --name gocron2-node \
3331
-v /path/to/my-task-scripts:/app \
3432
--net host \
35-
sstc/gocron:all gocron-node -allow-root
33+
sstc/gocron2 /gocron2/gocron2-node -allow-root
34+
35+
# Open 127.0.0.1:5920 to install
3636
```
3737

38-
> Multiple nodes
38+
> Multiple nodes with certs
3939
4040
```bash
41-
# Step 1: Create certs for main node
41+
# Create certs for main node
4242
docker run --rm \
43-
-v /path/to/out:/gocron/out \
44-
sstc/gocron:all ./init-cert.sh
43+
-v /path/to/out:/gocron2/out \
44+
sstc/gocron2 ./init-cert.sh
4545

46-
# Step 2: Create certs for worker nodes, do it multiple times with all ips of nodes
46+
# Create certs for worker nodes
4747
docker run --rm \
48-
-v /path/to/out:/gocron/out \
49-
sstc/gocron:all ./init-cert.sh 1.2.3.4
50-
51-
# Step 3: Up main node
52-
docker run -d --name gocron \
53-
-v /path/to/conf:/gocron/conf \
54-
-v /path/to/log:/gocron/log \
55-
-v /path/to/out:/gocron/out \
56-
-p 5920:5920 \
57-
sstc/gocron:latest
58-
59-
# Step 4: Open 127.0.0.1:5920 to install
48+
-v /path/to/out:/gocron2/out \
49+
sstc/gocron2 ./init-cert.sh 1.2.3.4
6050

61-
# Step 5: Add those to /path/to/conf/app.ini
51+
# Configure main node: add those to /path/to/conf/app.ini
6252
# enable_tls = true
63-
# ca_file = /gocron/out/Root_CA.crt
64-
# cert_file = /gocron/out/127.0.0.1.crt
65-
# key_file = /gocron/out/127.0.0.1.key
66-
67-
# Step 6: Restart main node
68-
docker restart gocron
53+
# ca_file = /gocron2/out/Root_CA.crt
54+
# cert_file = /gocron2/out/127.0.0.1.crt
55+
# key_file = /gocron2/out/127.0.0.1.key
56+
57+
# Up main node
58+
docker run -d --name gocron2 \
59+
-v /path/to/conf:/gocron2/conf \
60+
-v /path/to/log:/gocron2/log \
61+
-v /path/to/out:/gocron2/out \
62+
-p 5920:5920 \
63+
sstc/gocron2:server
6964

70-
# Step 7: Copy necessary files in /path/to/out to hosts of worker nodes
65+
# Copy cert files in /path/to/out for the worker nodes
7166

72-
# Step 6: Go to hosts and run, do this multiple times to up all worker nodes
73-
docker run -d --name gocron-node \
74-
-v /path/to/out:/gocron/out \
67+
# Up all worker nodes
68+
docker run -d --name gocron2-node \
69+
-v /path/to/out:/gocron2/out \
7570
-v /path/to/my-task-scripts:/app \
7671
-p 5921:5921 \
77-
sstc/gocron:all gocron-node -allow-root \
72+
sstc/gocron2 gocron2-node -allow-root \
7873
-enable-tls \
79-
-ca-file /gocron/out/Root_CA.crt \
80-
-cert-file /gocron/out/1.2.3.4.crt \
81-
-key-file /gocron/out/1.2.3.4.key
74+
-ca-file /gocron2/out/Root_CA.crt \
75+
-cert-file /gocron2/out/1.2.3.4.crt \
76+
-key-file /gocron2/out/1.2.3.4.key
77+
78+
# Open 127.0.0.1:5920 to install
8279
```

0 commit comments

Comments
 (0)