Skip to content

Commit 3213882

Browse files
Reduce the Docker scripts size
1 parent 2c5c03e commit 3213882

File tree

3 files changed

+61
-51
lines changed

3 files changed

+61
-51
lines changed

scripts/Dockerfile

+53-50
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,66 @@
1+
# Copyright 2022
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
115
################################################################################
216
# Image of a machine with installed swagger-combine and starport.
317
################################################################################
418

5-
FROM node
6-
7-
# Install golang
8-
ARG GO_VERSION
9-
ENV GO_VERSION=${GO_VERSION:-1.17.2}
10-
ENV BASH_ENV=/etc/bashrc
11-
ENV PATH="${PATH}:/usr/local/go/bin"
12-
RUN curl -L https://golang.org/dl/go${GO_VERSION}.linux-amd64.tar.gz -o /tmp/go.tar.gz \
13-
&& rm -rf /usr/local/go \
14-
&& tar -C /usr/local -xzf /tmp/go.tar.gz \
15-
&& go version \
16-
&& rm -f /tmp/go.tar.gz
17-
18-
# Install protoc
19-
ARG PROTOC_VERSION
20-
ENV PROTOC_VERSION=${PROTOC_VERSION:-3.19.4}
21-
RUN PROTOC_ZIP=protoc-${PROTOC_VERSION}-linux-x86_64.zip \
22-
&& curl -OL https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VERSION}/${PROTOC_ZIP} \
23-
&& unzip -o $PROTOC_ZIP -d /usr/local bin/protoc \
24-
&& unzip -o $PROTOC_ZIP -d /usr/local 'include/*' \
25-
&& rm -f $PROTOC_ZIP
26-
27-
# Install grpc-gateway tools
28-
ENV PROTOC_GEN_GRPC_GATEWAY_VERSION=v2.8.0
29-
ENV PROTOC_GEN_OPENAPIV2_VERSION=v2.8.0
30-
ENV PROTOC_GEN_SWAGGER_VERSION=v1.16.0
19+
FROM alpine:3.15 as builder
3120

32-
RUN go install \
33-
github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway@${PROTOC_GEN_GRPC_GATEWAY_VERSION} \
34-
github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2@${PROTOC_GEN_OPENAPIV2_VERSION}
35-
36-
RUN go install \
37-
github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger@${PROTOC_GEN_SWAGGER_VERSION}
21+
ARG STARPORT_VERSION
3822

39-
RUN npm install -g swagger-combine
23+
ENV STARPORT_VERSION=${STARPORT_VERSION:-v0.19.3}
24+
#ENV STARPORT_VERSION=${STARPORT_VERSION:-dev}
4025

26+
RUN apk --no-cache add \
27+
make=4.3-r0 \
28+
go=1.17.4-r0 \
29+
git=2.34.1-r0 \
30+
bash=5.1.16-r0
4131

4232
# Install starport
43-
ARG STARPORT_VERSION
44-
ENV STARPORT_VERSION=${STARPORT_VERSION:-0.19.3}
45-
#ENV STARPORT_VERSION=${STARPORT_VERSION:-dev}
33+
WORKDIR /tmp
34+
RUN git clone https://github.com/tendermint/starport.git \
35+
&& if [ "$STARPORT_VERSION" != "dev" ]; then \
36+
git -C /tmp/starport checkout -b ${STARPORT_VERSION:-v0.19.3} tags/${STARPORT_VERSION:-v0.19.3}; \
37+
fi \
38+
&& make -C /tmp/starport build
4639

47-
RUN if [ "$STARPORT_VERSION" = "dev" ]; then \
48-
curl -L https://github.com/tendermint/starport/archive/refs/heads/develop.zip -o /tmp/starport.zip && \
49-
cd /tmp \
50-
&& unzip starport.zip \
51-
&& cd starport-develop \
52-
&& make build \
53-
&& cp ./dist/starport /usr/local/bin; \
54-
else \
55-
curl https://get.starport.network/starport@v${STARPORT_VERSION}! -o /tmp/startport \
56-
&& bash /tmp/startport \
57-
&& rm /tmp/startport; \
58-
fi
40+
FROM alpine:3.15
5941

42+
ENV PROTOC_GEN_GRPC_GATEWAY_VERSION=v2.8.0
43+
ENV PROTOC_GEN_OPENAPIV2_VERSION=v2.8.0
44+
ENV PROTOC_GEN_SWAGGER_VERSION=v1.16.0
6045
ENV PATH="/root/go/bin:${PATH}"
61-
ENV PATH="${PATH}:/usr/local/bin"
6246

63-
WORKDIR /dcl
47+
COPY --from=builder /tmp/starport/dist/starport /usr/local/bin/starport
48+
49+
RUN apk --no-cache add \
50+
bash=5.1.16-r0 \
51+
git=2.34.1-r0 \
52+
go=1.17.4-r0 \
53+
protobuf=3.18.1-r1 \
54+
protobuf-dev=3.18.1-r1 \
55+
npm=8.1.3-r0 \
56+
&& npm install -g swagger-combine@1.4.0
57+
58+
# Install grpc-gateway tools
59+
60+
RUN go install \
61+
github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway@${PROTOC_GEN_GRPC_GATEWAY_VERSION} \
62+
github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2@${PROTOC_GEN_OPENAPIV2_VERSION} \
63+
&& go install \
64+
github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger@${PROTOC_GEN_SWAGGER_VERSION}
65+
66+
WORKDIR /dcl

scripts/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ docker build -t <name[:tag]> ./scripts
2020
Run docker container (from the root of the project) in an interactive mode:
2121

2222
```bash
23-
docker run -it -v "$PWD":/dcl <name[:tag]> /bin/bash
23+
docker run -it --rm -v "$PWD":/dcl <name[:tag]> /bin/bash
2424
```
2525

2626
## Scripts

scripts/cosmos-swagger-gen.sh

+7
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515

16+
set -o pipefail
17+
set -o errexit
18+
set -o nounset
19+
if [[ "${DEBUG:-false}" == "true" ]]; then
20+
set -o xtrace
21+
fi
22+
1623
TYPE=${1:-tx}
1724
valid_values=(base tx)
1825
if ! printf '%s\0' "${valid_values[@]}" | grep -qxFe "$TYPE"; then

0 commit comments

Comments
 (0)