-
Notifications
You must be signed in to change notification settings - Fork 5
/
Dockerfile_kicad-auto
203 lines (178 loc) · 6.73 KB
/
Dockerfile_kicad-auto
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
# We are going to use the latest version of ubuntu, of course
FROM ubuntu:22.04
LABEL org.opencontainers.image.authors "Leandor S. Heck <[email protected]>"
LABEL org.opencontainers.image.description "Kicad 6 with KiRI (Kicad Revision Inspector"
LABEL org.opencontainers.image.url "https://hub.docker.com/r/leoheck/kiri/tags"
LABEL org.opencontainers.image.documentation "https://github.com/leoheck/kiri-docker"
ARG DEBIAN_FRONTEND noninteractive
ARG DEBCONF_NOWARNINGS="yes"
ARG TERM 'dumb'
RUN apt-get update
RUN apt-get install -y \
sudo \
git \
zsh \
curl \
coreutils \
software-properties-common \
x11-utils \
x11-xkb-utils \
xvfb \
opam \
build-essential \
pkg-config \
libgmp-dev \
util-linux \
python-is-python3 \
python3-pip \
dos2unix \
librsvg2-bin \
imagemagick \
xdotool \
rename \
bsdmainutils ;\
apt-get clean ;\
rm -rf /var/lib/apt/lists/* ;\
rm -rf /var/tmp/*
# install latest kicad 6.0.*
RUN add-apt-repository -y ppa:kicad/kicad-6.0-releases
RUN apt-get install --no-install-recommends -y kicad && \
apt-get purge -y \
software-properties-common ;\
apt-get clean ;\
rm -rf /var/lib/apt/lists/* ;\
rm -rf /var/tmp/*
# create user
RUN useradd -rm -d "/home/kiri" -s "/usr/bin/zsh" -g root -G sudo -u 1000 kiri -p kiri
# run sudo without password
RUN echo "kiri ALL=(ALL) NOPASSWD:ALL" | tee sudo -a "/etc/sudoers"
# change user
USER kiri
WORKDIR "/home/kiri"
ENV USER kiri
ENV DISPLAY :0
ENV PATH "${PATH}:/home/kiri/.local/bin"
# python dependencies
RUN yes | pip3 install \
"pillow>8.2.0" \
"six>=1.15.0" \
"python_dateutil>=2.8.1" \
"pytz>=2021.1" \
"pathlib>=1.0.1" && \
pip3 cache purge
# opam dependencies
RUN yes | opam init --disable-sandboxing && \
opam switch create 4.10.2 && \
eval "$(opam env)" && \
opam update && \
opam install -y \
digestif \
lwt \
lwt_ppx \
cmdliner \
base64 \
sha \
tyxml \
git-unix ;\
opam clean -a -c -s --logs -r ;\
rm -rf ~/.opam/download-cache ;\
rm -rf ~/.opam/repo/*
# oh-my-zsh, please
RUN zsh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)" || true
# install kiri, kidiff and plotgitsch
ADD https://api.github.com/repos/leoheck/kiri/git/refs/heads/main kiri_version.json
ENV KIRI_HOME "/home/kiri/.local/share/"
RUN git clone --recurse-submodules -j8 https://github.com/leoheck/kiri.git "${KIRI_HOME}/kiri"
RUN cd "${KIRI_HOME}/kiri/submodules/plotkicadsch" && \
opam pin add -y kicadsch . && \
opam pin add -y plotkicadsch . && \
opam install -y plotkicadsch; \
opam clean -a -c -s --logs -r ;\
rm -rf ~/.opam/download-cache ;\
rm -rf ~/.opam/repo/*
# opam configuration
RUN echo | tee -a "${HOME}/.zshrc"
RUN echo '# OPAM configuration' | tee -a "${HOME}/.zshrc"
RUN echo "test -r /home/kiri/.opam/opam-init/init.sh && . /home/kiri/.opam/opam-init/init.sh > /dev/null 2> /dev/null || true" | tee -a "${HOME}/.zshrc"
# kiri environment
RUN echo | tee -a "${HOME}/.zshrc"
RUN echo '# KIRI Environment' | tee -a "${HOME}/.zshrc"
RUN echo 'export KIRI_HOME=${HOME}/.local/share/kiri' | tee -a "${HOME}/.zshrc"
RUN echo 'export PATH=${KIRI_HOME}/submodules/KiCad-Diff/bin:${PATH}' | tee -a "${HOME}/.zshrc"
RUN echo 'export PATH=${KIRI_HOME}/bin:${PATH}' | tee -a "${HOME}/.zshrc"
# custom commands
RUN echo | tee -a "${HOME}/.zshrc"
RUN echo '# Custom Commands' | tee -a "${HOME}/.zshrc"
RUN echo 'function ip() { awk "/32 host/ { print f } {f=\$2}" /proc/net/fib_trie | sort | uniq | grep -v 127.0.0.1 | head -n1 }' | tee -a "${HOME}/.zshrc"
RUN echo 'alias kiri="kiri -i \$(ip)"' | tee -a "${HOME}/.zshrc"
# clean unnecessary stuff
RUN sudo apt-get purge -y \
curl \
opam \
build-essential \
pkg-config \
libgmp-dev
RUN sudo apt-get -y autoremove
RUN sudo rm -rf \
/tmp/* \
/var/tmp/* \
/usr/share/doc/* \
/usr/share/info/* \
/usr/share/man/*
# initialize kicad config files to skip default popups of setup
COPY config /home/kiri/.config
RUN sudo chown -R kiri /home/kiri/.config
ARG DEBIAN_FRONTEND noninteractive
RUN sudo apt-get update && \
sudo apt-get install -y \
apt-utils && \
sudo apt-get install -y \
unrar-free \
wget \
curl \
bzip2 \
librsvg2-bin \
ghostscript && \
sudo apt-get install -y --no-install-recommends \
python3-qrcodegen \
poppler-utils && \
curl -s https://api.github.com/repos/INTI-CMNB/KiAuto/releases/latest | grep "browser_download_url.*deb" | cut -d : -f 2,3 | tr -d \" | wget -i - && \
curl -s https://api.github.com/repos/INTI-CMNB/KiBoM/releases/latest | grep "browser_download_url.*deb" | cut -d : -f 2,3 | tr -d \" | wget -i - && \
curl -s https://api.github.com/repos/INTI-CMNB/InteractiveHtmlBom/releases/latest | grep "browser_download_url.*deb" | cut -d : -f 2,3 | tr -d \" | wget -i - && \
curl -s https://api.github.com/repos/INTI-CMNB/PcbDraw/releases/latest | grep "browser_download_url.*deb" | cut -d : -f 2,3 | tr -d \" | wget -i - && \
curl -s https://api.github.com/repos/hildogjr/KiCost/releases/latest | grep "browser_download_url.*deb" | cut -d : -f 2,3 | tr -d \" | wget -i - && \
curl -s https://api.github.com/repos/INTI-CMNB/KiBot/releases/latest | grep "browser_download_url.*deb" | cut -d : -f 2,3 | tr -d \" | wget -i - && \
curl -s https://api.github.com/repos/set-soft/kicost-digikey-api-v3/releases/latest | grep "browser_download_url.*deb" | cut -d : -f 2,3 | tr -d \" | wget -i - && \
curl -s https://api.github.com/repos/INTI-CMNB/kicad-git-filters/releases/latest | grep "browser_download_url.*deb" | cut -d : -f 2,3 | tr -d \" | wget -i -
RUN sudo ln -fs /usr/share/zoneinfo/America/New_York /etc/localtime
RUN sudo apt-get install -y --no-install-recommends tzdata
RUN sudo apt install -y --no-install-recommends \
./python3-pymeta_0.5.1-1_all.deb \
./python3-pcbnewtransition_0.2.0-1_all.deb \
./python3-pybars_0.9.7-1_all.deb \
./python3-svgpathtools_1.4.1-1_all.deb \
./python3-validators_0.14.2-2_all.deb \
./kiauto_2.1.0-1_all.deb \
./kibom.inti-cmnb_1.8.0-3_all.deb \
./interactivehtmlbom.inti-cmnb_2.5.0-2_all.deb \
./pcbdraw_0.9.0-5_all.deb \
./kicost-digikey-api-v3_0.1.1-1_all.deb \
./kicost-digikey-api-v3_0.1.2-1_all.deb \
./kibot_1.5.1-1_all.deb \
./kicad-git-filters_1.0.1-1_all.deb && \
sudo rm *.deb && \
sudo apt-get purge -y \
apt-utils \
wget \
curl && \
sudo apt-get -y autoremove && \
sudo rm -rf /var/lib/apt/lists/*
RUN sudo sed -i 's/<policy domain="coder" rights="none" pattern="PDF" \/>/<!-- <policy domain="coder" rights="none" pattern="PDF" \/> -->/g' /etc/ImageMagick-6/policy.xml && \
sudo sed -i 's/<policy domain="coder" rights="none" pattern="PS" \/>/<!-- <policy domain="coder" rights="none" pattern="PS" \/> -->/g' /etc/ImageMagick-6/policy.xml
RUN sudo apt-get -y autoremove
RUN sudo rm -rf \
/tmp/* \
/var/tmp/* \
/usr/share/doc/* \
/usr/share/info/* \
/usr/share/man/*