1、 Problem description
Recently, the source code of fabric2 needs to be modified. Every time you want to deploy the test after the modification, the command make docker runs very slowly. Readers who find this article should encounter the same problems as me. This paper will analyze the causes of the problems and propose solutions.
2、 Problem analysis
Fabric’s image is based on Alpine (Alpine Linux is a security oriented, lightweight Linux distribution based on musl libc and busybox projects). The package management tool of Alpine is APK, and the default source of Alpine system is foreign countries. Therefore, it will be very slow to install software in the image container created based on Alpine. For example, the most time-consuming installation is “installing GCC”, which really takes half a day.
The solution to the above problem is simple: replace the source of the image container.
This paper will use the open source software of Tsinghua University http://mirrors.tuna.tsinghua…. , V3.11 is the version number of Alpine.
How to source the fabric image container? The specific steps are as follows:
- Enter the images directory in the fabric source code. There are five subdirectories under this directory, and each directory contains a dockerfile. As shown in the figure below:
- Modify each dockerfile file in turn, and add code in the corresponding location:
RUN echo -e http://mirrors.tuna.tsinghua.edu.cn/alpine/v3.11/main/ > /etc/apk/repositories
The modified dockerfile file content is shown in the following figure:
After modifying the five dockerfiles, run make docker in the root directory of fabric source code, which is as fast as the wind.
This paper is published by openwrite, an operation tool platform for blog group post, multi post, etc