-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathDockerfile-dev
More file actions
152 lines (137 loc) · 4.71 KB
/
Copy pathDockerfile-dev
File metadata and controls
152 lines (137 loc) · 4.71 KB
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
ARG image_repo=rust
ARG image_tag=bookworm
FROM ${image_repo}:${image_tag} AS volttron_base
ARG volttron_repo=https://github.com/VOLTTRON/volttron.git
ARG volttron_git_branch=develop
#
SHELL [ "bash", "-c" ]
#
ENV OS_TYPE=debian
ENV DIST=bookworm
ENV VOLTTRON_GIT_BRANCH=${volttron_git_branch}
ENV VOLTTRON_USER_HOME=/home/volttron
ENV VOLTTRON_HOME=${VOLTTRON_USER_HOME}/.volttron
ENV CODE_ROOT=/code
ENV VOLTTRON_ROOT=${CODE_ROOT}/volttron
ENV VOLTTRON_USER=volttron
ENV USER_PIP_BIN=${VOLTTRON_USER_HOME}/.local/bin
ENV CONFIG=/home/volttron/configs
ENV TZ=UTC
ENV LOCAL_USER_ID=1000
#ENV RMQ_ROOT=${VOLTTRON_USER_HOME}/rabbitmq_server
#ENV RMQ_HOME=${RMQ_ROOT}/rabbitmq_server-3.7.7
#
USER root
RUN set -eux; apt-get update; apt-get install -y --no-install-recommends \
procps \
gosu \
vim \
tree \
build-essential \
python3-dev \
python3-pip \
python3-setuptools \
python3-venv \
python3-wheel \
openssl \
libssl-dev \
libevent-dev \
git \
gnupg \
dirmngr \
apt-transport-https \
wget \
curl \
ca-certificates \
libffi-dev \
sqlite3
#
# Set default 'python' to 'python3'
RUN update-alternatives --install /usr/bin/python python /usr/bin/python3 1
#
# Set global.break-system-packages to true to allow pip to install packages
#
RUN python3 -m pip config set global.break-system-packages true
#
# Upgrade pip so that we get a pre-compiled wheel for 'cryptopgraphy', which is a dependency of Volttron
# See https://cryptography.io/en/latest/faq/#installing-cryptography-fails-with-error-can-not-find-rust-compiler
RUN pip install --upgrade pip
#
# Install rust and cargo
#
RUN rustup default stable
#
# Create a user called 'volttron'
RUN id -u $VOLTTRON_USER &>/dev/null || adduser --disabled-password --gecos "" $VOLTTRON_USER
#
RUN mkdir -p /code && chown $VOLTTRON_USER.$VOLTTRON_USER /code && \
echo "export PATH=/home/volttron/.local/bin:$PATH" > /home/volttron/.bashrc
#
############################################
# ENDING volttron_base stage
# Creating volttron_core stage
############################################
FROM volttron_base AS volttron_core
ARG volttron_repo=https://github.com/VOLTTRON/volttron.git
ARG volttron_git_branch=develop
# copy over /core, i.e. the custom startup scripts for this image
RUN mkdir /startup $VOLTTRON_HOME && \
chown $VOLTTRON_USER.$VOLTTRON_USER $VOLTTRON_HOME
COPY --chown=volttron:volttron ./core /startup
RUN chmod +x /startup/*
#
# copy over volttron repo
USER $VOLTTRON_USER
RUN git clone --branch ${volttron_git_branch} --single-branch ${volttron_repo} ${VOLTTRON_ROOT}
WORKDIR ${VOLTTRON_ROOT}
#
# Set global.break-system-packages to true to allow pip to install packages
#
RUN python3 -m pip config set global.break-system-packages true
#
# Upgrade pip so that we get a pre-compiled wheel for 'cryptography', which is a dependency of Volttron
# See https://cryptography.io/en/latest/faq/#installing-cryptography-fails-with-error-can-not-find-rust-compiler
RUN pip install --upgrade pip
#
# Now install volttron required packages
#
RUN pip install -e . --user
RUN echo "package installed at `date`"
#
#############################################
## RABBITMQ SPECIFIC INSTALLATION
#############################################
## the ARG install_rmq must be declared twice due to scope; see https://docs.docker.com/engine/reference/builder/#using-arg-variables
#USER root
#ARG install_rmq
#RUN if [ "${install_rmq}" = "false" ] ; then \
# echo "Not installing RMQ dependencies."; \
# else \
# ./scripts/rabbit_dependencies.sh $OS_TYPE $DIST && \
# python -m pip install gevent-pika; \
# fi
##
#USER $VOLTTRON_USER
#ARG install_rmq
#RUN if [ "${install_rmq}" = "false" ] ; then \
# echo "Not installing RMQ"; \
# else \
# mkdir $RMQ_ROOT && \
# set -eux && \
# wget -P $VOLTTRON_USER_HOME https://github.com/rabbitmq/rabbitmq-server/releases/download/v3.7.7/rabbitmq-server-generic-unix-3.7.7.tar.xz && \
# tar -xf $VOLTTRON_USER_HOME/rabbitmq-server-generic-unix-3.7.7.tar.xz --directory $RMQ_ROOT && \
# $RMQ_HOME/sbin/rabbitmq-plugins enable rabbitmq_management rabbitmq_federation rabbitmq_federation_management rabbitmq_shovel rabbitmq_shovel_management rabbitmq_auth_mechanism_ssl rabbitmq_trust_store; \
# fi
############################################
RUN python -m pip install zmq
########################################
# The following lines should be run from any Dockerfile that
# is inheriting from this one as this will make the volttron
# run in the proper location.
#
# The user must be root at this point to allow gosu to work
########################################
USER root
WORKDIR ${VOLTTRON_USER_HOME}
ENTRYPOINT ["/startup/entrypoint.sh"]
CMD ["/startup/bootstart.sh"]