-
Notifications
You must be signed in to change notification settings - Fork 2
/
Dockerfile
82 lines (70 loc) · 2.97 KB
/
Dockerfile
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
ARG DEBUG_APT=/dev/stdout
FROM ubuntu:bionic AS embryo
MAINTAINER Martin Kjellstrand [https://www.github.com/madworx]
ARG PYTHON_VERSION
ARG VCS_REF
ARG DEBUG_APT
LABEL org.label-schema.vcs-url="https://github.com/madworx/robotframework-kicadlibrary/" \
org.label-schema.vcs-ref=${VCS_REF} \
maintainer="Martin Kjellstrand [https://www.github.com/madworx]"
SHELL [ "/bin/bash", "-c" ]
RUN if [[ "${PYTHON_VERSION}" == 3* ]] ; then PYPKG="python3" ; KIREPO="5.1" ; else PYPKG="python" ; KIREPO="5" ; fi \
&& echo "Adding 'ppa:kicad/kicad-${KIREPO}-releases' with '${PYPKG}'..." \
&& apt-get -qq update < /dev/null > ${DEBUG_APT} \
&& apt-get -qq install --no-install-recommends --assume-yes software-properties-common locales make < /dev/null > ${DEBUG_APT} \
&& echo "C.UTF-8 UTF-8" > /etc/locale.gen && locale-gen \
&& add-apt-repository -y ppa:kicad/kicad-${KIREPO}-releases < /dev/null > ${DEBUG_APT} \
&& dpkg --purge software-properties-common < /dev/null > ${DEBUG_APT} \
&& apt-get -qq update < /dev/null > ${DEBUG_APT} \
&& apt-get install --assume-yes --no-install-recommends "${PYPKG}" "${PYPKG}-pip" < /dev/null > ${DEBUG_APT} \
&& if [[ "${PYTHON_VERSION}" == 3* ]] ; then ln -sf python3 /usr/bin/python ; ln -sf pip3 /usr/bin/pip ; fi \
&& apt-get install -qq --assume-yes --no-install-recommends kicad kicad-symbols kicad-footprints < /dev/null > ${DEBUG_APT} \
&& apt-get autoremove -y < /dev/null > ${DEBUG_APT} \
&& apt-get update -o'Dir::Etc::SourceList=/dev/null' -o'Dir::Etc::SourceParts=/tmp' \
&& apt-get clean
FROM embryo AS build
#
# We are relying on the builder to set the KICADLIBRARY_VERSION
# variable, to not having to install setuptools_scm and git. (Plus
# having to deal with if this repository is checked out as a git
# submodule (in which case the build would fail any way).
#
ARG KICADLIBRARY_VERSION
ARG DEBUG_APT
RUN if [ -z "${KICADLIBRARY_VERSION}" ] ; then \
echo "FATAL: Build variable KICADLIBRARY_VERSION must be specified for docker builds!" 1>&2 \
; exit 1 \
; fi
RUN echo "Installing setuptools into build environment..." \
&& pip install setuptools setuptools_scm wheel
COPY . /build
WORKDIR /build
RUN make distclean
RUN echo "Building version ${KICADLIBRARY_VERSION}."
RUN sed -e "s#'setuptools_scm', ##g" \
-e "/use_scm_version/d" \
-e "s/#version=.*/version='${KICADLIBRARY_VERSION}',/g" \
-i setup.py
# Run unit-tests and build wheel.
RUN make dist doc
RUN pip install dist/*.whl
# Run integration tests
RUN cd examples \
&& for DIR in * ; do \
( cd "${DIR}" && robot . ) \
; done
FROM embryo
COPY --from=build \
/build/dist/*.whl \
/build/dist/*.tar.gz \
/build/docs/*.html \
/build/build \
/build/
RUN pip install /build/*.whl
RUN useradd --base-dir / \
--system \
--user-group \
--create-home \
robot
USER robot
ENTRYPOINT [ "/usr/local/bin/robot" ]