generated from duckietown/template-book
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile
101 lines (90 loc) · 3.2 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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# syntax=docker/dockerfile:1.4
# parameters
ARG PROJECT_NAME
ARG PROJECT_DESCRIPTION
ARG PROJECT_MAINTAINER
# pick an icon from: https://fontawesome.com/v4.7.0/icons/
ARG PROJECT_ICON="book"
ARG PROJECT_FORMAT_VERSION
# ==================================================>
# ==> Do not change the code below this line
ARG ARCH
ARG DISTRO
ARG DOCKER_REGISTRY
ARG BASE_REPOSITORY
ARG BASE_ORGANIZATION=duckietown
ARG BASE_TAG=${DISTRO}-${ARCH}
# define base image
FROM ${DOCKER_REGISTRY}/${BASE_ORGANIZATION}/${BASE_REPOSITORY}:${BASE_TAG} as base
# recall all arguments
ARG ARCH
ARG DISTRO
ARG DOCKER_REGISTRY
ARG PROJECT_NAME
ARG PROJECT_DESCRIPTION
ARG PROJECT_MAINTAINER
ARG PROJECT_FORMAT_VERSION
ARG BASE_TAG
ARG BASE_REPOSITORY
ARG BASE_ORGANIZATION
# - buildkit
ARG TARGETPLATFORM
ARG TARGETOS
ARG TARGETARCH
ARG TARGETVARIANT
# check build arguments
RUN dt-args-check \
"PROJECT_NAME" "${PROJECT_NAME}" \
"PROJECT_DESCRIPTION" "${PROJECT_DESCRIPTION}" \
"PROJECT_MAINTAINER" "${PROJECT_MAINTAINER}" \
"PROJECT_FORMAT_VERSION" "${PROJECT_FORMAT_VERSION}" \
"ARCH" "${ARCH}" \
"DISTRO" "${DISTRO}" \
"DOCKER_REGISTRY" "${DOCKER_REGISTRY}" \
"BASE_REPOSITORY" "${BASE_REPOSITORY}" \
&& dt-check-project-format "${PROJECT_FORMAT_VERSION}"
# define/create repository path
ARG PROJECT_PATH="${SOURCE_DIR}/${PROJECT_NAME}"
RUN mkdir -p "${PROJECT_PATH}"
WORKDIR "${PROJECT_PATH}"
# keep some arguments as environment variables
ENV DT_PROJECT_NAME="${PROJECT_NAME}" \
DT_PROJECT_DESCRIPTION="${PROJECT_DESCRIPTION}" \
DT_PROJECT_MAINTAINER="${PROJECT_MAINTAINER}" \
DT_PROJECT_ICON="${PROJECT_ICON}" \
DT_PROJECT_PATH="${PROJECT_PATH}"
# install apt dependencies
COPY ./dependencies-apt.txt "${PROJECT_PATH}/"
RUN dt-apt-install ${PROJECT_PATH}/dependencies-apt.txt
# install python3 dependencies
ARG PIP_INDEX_URL="https://pypi.org/simple"
ENV PIP_INDEX_URL=${PIP_INDEX_URL}
COPY ./dependencies-py3.* "${PROJECT_PATH}/"
RUN dt-pip3-install "${PROJECT_PATH}/dependencies-py3.*"
# store module metadata
LABEL \
# module info
org.duckietown.label.project.name="${PROJECT_NAME}" \
org.duckietown.label.project.description="${PROJECT_DESCRIPTION}" \
org.duckietown.label.project.maintainer="${PROJECT_MAINTAINER}" \
org.duckietown.label.project.icon="${PROJECT_ICON}" \
org.duckietown.label.project.path="${PROJECT_PATH}" \
org.duckietown.label.project.launchers.path="" \
# format
org.duckietown.label.format.version="${PROJECT_FORMAT_VERSION}" \
# platform info
org.duckietown.label.platform.os="${TARGETOS}" \
org.duckietown.label.platform.architecture="${TARGETARCH}" \
org.duckietown.label.platform.variant="${TARGETVARIANT}" \
# code info
org.duckietown.label.code.distro="${DISTRO}" \
org.duckietown.label.code.launcher="" \
org.duckietown.label.code.python.registry="${PIP_INDEX_URL}" \
# base info
org.duckietown.label.base.organization="${BASE_ORGANIZATION}" \
org.duckietown.label.base.repository="${BASE_REPOSITORY}" \
org.duckietown.label.base.tag="${BASE_TAG}"
# <== Do not change the code above this line
# <==================================================
# copy source (if given)
COPY --from=source . ${JB_SOURCE_DIR}