-
Notifications
You must be signed in to change notification settings - Fork 4
/
.drone.yml
157 lines (147 loc) · 4.01 KB
/
.drone.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
---
name: build
kind: pipeline
type: docker
steps:
- name: get bin
image: m.daocloud.io/docker.io/ubuntu:22.04
environment:
HTTPS_PROXY:
from_secret: HTTPS_PROXY
HTTP_PROXY:
from_secret: HTTP_PROXY
NO_PROXY:
from_secret: NO_PROXY
commands:
- apt update
- apt install -y curl
- curl -fSL -O 'https://github.com/cloudflare/workerd/releases/download/v1.20240725.0/workerd-linux-64.gz'
- gzip -d workerd-linux-64.gz
- mv workerd-linux-64 bin/workerd
- name: pull and cache image
image: docker:dind
environment:
DOCKER_PASSWORD:
from_secret: docker_password
DOCKER_USERNAME:
from_secret: docker_username
volumes:
- name: dockersock
path: /var/run
failure: ignore
depends_on:
- get bin
commands:
- echo $DOCKER_PASSWORD | docker login --username $DOCKER_USERNAME --password-stdin
- docker info
- docker build -t vaalacat/vorker .
- name: cahce go package
image: golang:1.22
commands:
- CGO_ENABLED=0 GOPROXY=https://goproxy.cn,direct go get
volumes:
- name: gocache
path: /go/pkg/mod
- name: build frontend
image: node:20-alpine
environment:
HTTPS_PROXY:
from_secret: HTTPS_PROXY
HTTP_PROXY:
from_secret: HTTP_PROXY
NO_PROXY:
from_secret: NO_PROXY
commands:
- cd www
- sed -i 's/dl-cdn.alpinelinux.org/mirrors.cernet.edu.cn/g' /etc/apk/repositories
- apk update --no-cache && apk add --no-cache tzdata git openssh curl
- mkdir -p ~/.ssh
- corepack enable
- corepack prepare pnpm@latest-9 --activate
- pnpm config set store-dir /root/.pnpm-store
- pnpm install --no-frozen-lockfile
- pnpm build
- pnpm export
volumes:
- name: nodecache
path: /drone/src/www/node_modules
- name: build backend
image: golang:1.22
commands:
- CGO_ENABLED=0 GOPROXY=https://goproxy.cn,direct go build -o vorker
depends_on:
- build frontend
volumes:
- name: gocache
path: /go/pkg/mod
- name: build and push version specific image
image: docker:dind
environment:
DOCKER_PASSWORD:
from_secret: docker_password
DOCKER_USERNAME:
from_secret: docker_username
volumes:
- name: dockersock
path: /var/run
commands:
- echo $DOCKER_PASSWORD | docker login --username $DOCKER_USERNAME --password-stdin
- docker info
- docker build -t vaalacat/vorker:v0.${DRONE_BUILD_NUMBER} .
- docker push vaalacat/vorker:v0.${DRONE_BUILD_NUMBER}
depends_on:
- build backend
- pull and cache image
- name: push latest image
image: docker:dind
environment:
DOCKER_PASSWORD:
from_secret: docker_password
DOCKER_USERNAME:
from_secret: docker_username
volumes:
- name: dockersock
path: /var/run
commands:
- echo $DOCKER_PASSWORD | docker login --username $DOCKER_USERNAME --password-stdin
- docker tag vaalacat/vorker:v0.${DRONE_BUILD_NUMBER} vaalacat/vorker:latest
- docker push vaalacat/vorker:latest
depends_on:
- build and push version specific image
when:
event:
- promote
target:
- production
services:
- name: docker
image: docker:dind
privileged: true
environment:
DOCKER_MIRROR:
from_secret: DOCKER_MIRROR
HTTPS_PROXY:
from_secret: HTTPS_PROXY
HTTP_PROXY:
from_secret: HTTP_PROXY
NO_PROXY:
from_secret: NO_PROXY
commands:
- dockerd --host=unix:///var/run/docker.sock --registry-mirror $DOCKER_MIRROR
volumes:
- name: dockersock
path: /var/run
- name: dockercache
path: /var/lib/docker
volumes:
- name: dockersock
temp: {}
- name: dockercache
host:
path: /tmp/dronedockercache
- name: gocache
host:
path: /tmp/dronecahe
- name: nodecache
host:
path: /tmp/drone/vorker/nodecache