-
-
Notifications
You must be signed in to change notification settings - Fork 43
/
build_images.sh
241 lines (182 loc) · 5.94 KB
/
build_images.sh
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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
#!/bin/bash
REPO=carlosedp
mkdir -p $GOPATH/src/github.com/openfaas
mkdir -p $GOPATH/src/github.com/nats-io
pushd $GOPATH/src/github.com/openfaas
git clone https://github.com/openfaas/faas-cli
git clone https://github.com/openfaas/faas-swarm
git clone https://github.com/openfaas/faas-netes
git clone https://github.com/openfaas/faas
git clone https://github.com/openfaas/nats-queue-worker/
git clone https://github.com/openfaas-incubator/faas-idler
# Build faas-cli
pushd faas-cli
CGO_ENABLED=0 GOOS=linux go build --ldflags "-s -w" -a -installsuffix cgo -o faas-cli
sudo cp faas-cli /usr/local/bin
popd
# Build faas-gateway
pushd faas/gateway
CGO_ENABLED=0 GOOS=linux go build --ldflags "-s -w" -a -installsuffix cgo -o gateway
cat <<EOF >>Dockerfile.riscv64
FROM carlosedp/debian:sid-riscv64
ARG ARCH="riscv64"
LABEL org.label-schema.license="MIT" \
org.label-schema.vcs-url="https://github.com/openfaas/faas" \
org.label-schema.vcs-type="Git" \
org.label-schema.name="openfaas/faas" \
org.label-schema.vendor="openfaas" \
org.label-schema.docker.schema-version="1.0"
RUN addgroup --system app \
&& adduser --system --ingroup app app \
&& apt-get update \
&& apt-get install -y ca-certificates
WORKDIR /home/app
EXPOSE 8080
EXPOSE 8082
ENV http_proxy ""
ENV https_proxy ""
COPY gateway .
COPY assets assets
RUN sed -ie s/x86_64/${ARCH}/g assets/script/funcstore.js && \
rm assets/script/funcstore.jse
RUN chown -R app:app ./
USER app
CMD ["./gateway"]
EOF
docker build -t $REPO/faas-gateway:riscv64 -f Dockerfile.riscv64 .
docker push $REPO/faas-gateway:riscv64
popd
# Build Watchdog
pushd faas/watchdog
CGO_ENABLED=0 GOOS=linux go build --ldflags "-s -w" -a -installsuffix cgo -o watchdog
cat <<EOF >>Dockerfile.riscv64
FROM scratch
COPY watchdog ./fwatchdog
EOF
docker build -t $REPO/faas-watchdog:riscv64 -f Dockerfile.riscv64 .
docker push $REPO/faas-watchdog:riscv64
popd
# Build Basic-Auth
pushd faas/auth/basic-auth
CGO_ENABLED=0 GOOS=linux go build --ldflags "-s -w" -a -installsuffix cgo -o handler
cat <<EOF >>Dockerfile.riscv64
FROM carlosedp/debian:sid-riscv64
RUN addgroup --system app \
&& adduser --system --ingroup app app
WORKDIR /home/app
COPY handler .
RUN chown -R app:app ./
USER app
CMD ["./handler"]
EOF
docker build -t $REPO/faas-basic-auth-plugin:riscv64 -f Dockerfile.riscv64 .
docker push $REPO/faas-basic-auth-plugin:riscv64
popd
# Build Nats-Queue-Worker
pushd nats-queue-worker
mv Dockerfile Dockerfile-orig
cat <<EOF >>Dockerfile
FROM carlosedp/golang:1.13 as golang
ENV CGO_ENABLED=0
WORKDIR /go/src/github.com/openfaas/nats-queue-worker
COPY vendor vendor
COPY handler handler
COPY nats nats
COPY main.go .
COPY types.go .
COPY readconfig.go .
COPY readconfig_test.go .
COPY auth.go .
ARG go_opts
RUN env $go_opts CGO_ENABLED=0 go build -a -installsuffix cgo -o app . \
&& addgroup --system app \
&& adduser --system --ingroup app app \
&& apt-get update \
&& apt-get install -y ca-certificates \
&& mkdir /scratch-tmp
# we can't add user in next stage because it's from scratch
# ca-certificates and tmp folder are also missing in scratch
# so we add all of it here and copy files in next stage
FROM scratch
EXPOSE 8080
ENV http_proxy ""
ENV https_proxy ""
USER app
COPY --from=golang /etc/passwd /etc/group /etc/
COPY --from=golang /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=golang --chown=app:app /scratch-tmp /tmp
COPY --from=golang /go/src/github.com/openfaas/nats-queue-worker/app .
CMD ["./app"]
EOF
make build-riscv64
docker tag openfaas/queue-worker:latest-riscv64 $REPO/faas-queue-worker:riscv64
docker rmi openfaas/queue-worker:latest-riscv64
docker push $REPO/faas-queue-worker:riscv64
popd
# Build Faas-Swarm
pushd faas-swarm
CGO_ENABLED=0 GOOS=linux go build --ldflags "-s -w" -a -installsuffix cgo -o fs
cat <<EOF >>Dockerfile.riscv64
FROM carlosedp/debian:sid-riscv64
LABEL org.label-schema.license="MIT" \
org.label-schema.vcs-url="https://github.com/openfaas/faas-swarm" \
org.label-schema.vcs-type="Git" \
org.label-schema.name="openfaas/faas-swarm" \
org.label-schema.vendor="openfaas" \
org.label-schema.docker.schema-version="1.0"
RUN apt-get update && apt-get install -y ca-certificates
WORKDIR /root/
EXPOSE 8080
ENV http_proxy ""
ENV https_proxy ""
COPY fs ./faas-swarm
CMD ["./faas-swarm"]
EOF
docker build -t $REPO/faas-swarm:riscv64 -f Dockerfile.riscv64 .
docker push $REPO/faas-swarm:riscv64
popd
# Build Faas-netes
pushd faas-netes
CGO_ENABLED=0 GOOS=linux go build --ldflags "-s -w" -a -installsuffix cgo -o faas-netes
cat <<EOF >>Dockerfile.riscv64
FROM carlosedp/debian:sid-riscv64
LABEL org.label-schema.license="MIT" \
org.label-schema.vcs-url="https://github.com/openfaas/faas-netes" \
org.label-schema.vcs-type="Git" \
org.label-schema.name="openfaas/faas-netes" \
org.label-schema.vendor="openfaas" \
org.label-schema.docker.schema-version="1.0"
RUN addgroup --system app && \
adduser --system app --ingroup app && \
apt-get update && \
apt-get install -y ca-certificates
WORKDIR /home/app
ADD faas-netes .
RUN chown -R app:app ./
EXPOSE 8080
ENV http_proxy ""
ENV https_proxy ""
USER app
CMD ["./faas-netes"]
EOF
docker build -t $REPO/faas-netes:riscv64 -f Dockerfile.riscv64 .
docker push $REPO/faas-netes:riscv64
popd
# Nats Streaming Server
pushd $GOPATH/src/github.com/nats-io
git clone https://github.com/nats-io/nats-streaming-server
pushd nats-streaming-server
CGO_ENABLED=0 GOOS=linux go build --ldflags "-s -w" -a -installsuffix cgo -o nats-streaming-server
cat <<EOF >>Dockerfile.riscv64
FROM scratch
COPY nats-streaming-server /nats-streaming-server
# Expose client and management ports
EXPOSE 4222 8222
# Run with default memory based store
ENTRYPOINT ["/nats-streaming-server"]
CMD ["-m", "8222"]
EOF
docker build -t $REPO/faas-nats-streaming:riscv64 -f Dockerfile.riscv64 .
docker push $REPO/faas-nats-streaming:riscv64
popd
popd