Skip to content

Commit 9b55769

Browse files
authored
Initial commit
0 parents  commit 9b55769

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+4094
-0
lines changed

.devcontainer/Dockerfile

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Copyright (c) 2022 Robert Bosch GmbH and Microsoft Corporation
2+
#
3+
# This program and the accompanying materials are made available under the
4+
# terms of the Apache License, Version 2.0 which is available at
5+
# https://www.apache.org/licenses/LICENSE-2.0.
6+
#
7+
# Unless required by applicable law or agreed to in writing, software
8+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
9+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10+
# License for the specific language governing permissions and limitations
11+
# under the License.
12+
#
13+
# SPDX-License-Identifier: Apache-2.0
14+
15+
FROM ghcr.io/eclipse-velocitas/devcontainer-base-images/python:v0.2
16+
17+
# Force dapr to use localhost traffic
18+
ENV DAPR_HOST_IP="127.0.0.1"
19+
# Add daprd to the path for the VS Code Dapr extension.
20+
ENV PATH=$PATH:/home/vscode/.dapr/bin
21+
22+
ENV DOCKER_BUILDKIT=1
23+
24+
COPY scripts/*.sh /tmp/scripts/
25+
RUN find /tmp/scripts/ -type f -iname "*.sh" -exec chmod +x {} \;
26+
RUN /bin/bash /tmp/scripts/container-set.sh
27+
RUN /bin/bash /tmp/scripts/configure-proxies.sh

.devcontainer/devcontainer.json

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
// This file is maintained by velocitas CLI, do not modify manually. Change settings in .velocitas.json
2+
{
3+
"name": "Python vehicle app",
4+
"build": {
5+
"dockerfile": "Dockerfile"
6+
},
7+
"runArgs": [
8+
"--init",
9+
"--privileged"
10+
],
11+
"containerEnv": {
12+
"GITHUB_API_TOKEN": "${localEnv:GITHUB_API_TOKEN}",
13+
"GIT_CONFIG_NAME": "${localEnv:GIT_CONFIG_NAME}",
14+
"GIT_CONFIG_EMAIL": "${localEnv:GIT_CONFIG_EMAIL}"
15+
},
16+
"customizations": {
17+
"vscode": {
18+
// Set *default* container specific settings.json values on container create.
19+
"settings": {
20+
"python.defaultInterpreterPath": "/usr/bin/python3",
21+
"python.analysis.typeCheckingMode": "basic",
22+
// Strong Type Checker
23+
"mypy.enabled": true,
24+
"mypy.runUsingActiveInterpreter": true,
25+
"mypy.targets": [
26+
"app"
27+
],
28+
// Security Linter
29+
"python.linting.banditEnabled": true,
30+
"python.linting.banditArgs": [
31+
"-c setup.cfg"
32+
],
33+
// Style Checker for Python Docs
34+
"python.linting.pydocstyleEnabled": true,
35+
"python.analysis.extraPaths": [
36+
"./proto",
37+
"./src/vehicle_model"
38+
],
39+
"python.testing.unittestEnabled": false,
40+
"python.testing.pytestEnabled": true,
41+
"[python]": {
42+
// Style Formatter
43+
"editor.defaultFormatter": "ms-python.black-formatter"
44+
},
45+
"vs-kubernetes": {
46+
"vscode-kubernetes.kubectl-path.linux": "/usr/local/bin/kubectl",
47+
"vscode-kubernetes.helm-path.linux": "/usr/local/bin/helm"
48+
},
49+
"terminal.integrated.defaultProfile.linux": "zsh",
50+
"terminal.integrated.profiles.linux": {
51+
"zsh": {
52+
"path": "/usr/bin/zsh"
53+
}
54+
},
55+
"vsmqtt.brokerProfiles": [
56+
{
57+
"name": "mosquitto (local)",
58+
"host": "localhost",
59+
"port": 1883,
60+
"clientId": "vsmqtt_client"
61+
},
62+
{
63+
"name": "mosquitto (k3d)",
64+
"host": "localhost",
65+
"port": 31883,
66+
"clientId": "vsmqtt_client"
67+
},
68+
{
69+
"name": "mosquitto (kanto)",
70+
"host": "localhost",
71+
"port": 1883,
72+
"clientId": "vsmqtt_client"
73+
}
74+
]
75+
},
76+
// Add the IDs of extensions you want installed when the container is created.
77+
"extensions": [
78+
"dbaeumer.vscode-eslint",
79+
"ms-azuretools.vscode-dapr",
80+
"ms-azuretools.vscode-docker",
81+
"ms-python.python",
82+
"cschleiden.vscode-github-actions",
83+
"rpdswtk.vsmqtt",
84+
"dotjoshjohnson.xml",
85+
"ms-kubernetes-tools.vscode-kubernetes-tools",
86+
"matangover.mypy",
87+
"augustocdias.tasks-shell-input",
88+
"ms-python.isort",
89+
"ms-python.flake8",
90+
"ms-python.black-formatter",
91+
"ms-python.mypy-type-checker"
92+
]
93+
}
94+
},
95+
"onCreateCommand": "bash .devcontainer/scripts/onCreateCommand.sh",
96+
"postStartCommand": "bash .devcontainer/scripts/postStartCommand.sh",
97+
// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
98+
"remoteUser": "vscode"
99+
}
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
#!/bin/bash
2+
# This file is maintained by velocitas CLI, do not modify manually. Change settings in .velocitas.json
3+
# Copyright (c) 2022 Robert Bosch GmbH and Microsoft Corporation
4+
#
5+
# This program and the accompanying materials are made available under the
6+
# terms of the Apache License, Version 2.0 which is available at
7+
# https://www.apache.org/licenses/LICENSE-2.0.
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12+
# License for the specific language governing permissions and limitations
13+
# under the License.
14+
#
15+
# SPDX-License-Identifier: Apache-2.0
16+
17+
echo "#######################################################"
18+
echo "### Configure-proxies ###"
19+
echo "#######################################################"
20+
21+
if [ "$HTTP_PROXY" != "" ]; then
22+
USE_PROXIES="true"
23+
CONFIGURE_GIT="true"
24+
FTP_PROXY=$HTTP_PROXY
25+
ALL_PROXY=$HTTP_PROXY
26+
NO_PROXY="localhost,127.0.0.1,0.0.0.0,10.0.0.0/8,192.168.122.0/24,172.0.0.0/8,cattle-system.svc,.svc,.cluster.local"
27+
fi
28+
29+
echo "Use proxies: $USE_PROXIES"
30+
echo "Http-proxy: $HTTP_PROXY"
31+
echo "Https-proxy: $HTTPS_PROXY"
32+
echo "Ftp-proxy: $FTP_PROXY"
33+
echo "All proxy: $ALL_PROXY"
34+
echo "No proxy: $NO_PROXY"
35+
echo "Configure git: $CONFIGURE_GIT"
36+
37+
set -e
38+
39+
if [ "$(id -u)" -ne 0 ]; then
40+
echo -e 'Script must be run as root. Use sudo, su, or add "USER root" to your Dockerfile before running this script.'
41+
exit 1
42+
fi
43+
44+
# Determine the appropriate non-root user
45+
# This recognizes the same possible user names found in Microsoft base Docker images
46+
# as the scripts in the ../library-scripts directory
47+
if [ "${USERNAME}" = "auto" ] || [ "${USERNAME}" = "automatic" ]; then
48+
USERNAME=""
49+
POSSIBLE_USERS=("vscode" "node" "codespace" "$(awk -v val=1000 -F ":" '$3==val{print $1}' /etc/passwd)")
50+
for CURRENT_USER in ${POSSIBLE_USERS[@]}; do
51+
if id -u ${CURRENT_USER} > /dev/null 2>&1; then
52+
USERNAME=${CURRENT_USER}
53+
break
54+
fi
55+
done
56+
elif [ "${USERNAME}" = "none" ] || ! id -u ${USERNAME} > /dev/null 2>&1; then
57+
USERNAME=root
58+
fi
59+
60+
if [ "${USERNAME}" = "" ]; then
61+
USERNAME=vscode
62+
fi
63+
echo "Selected user name is ${USERNAME}"
64+
65+
if [ "${USE_PROXIES}" = "true" ]; then
66+
echo "Configuring proxies"
67+
68+
mkdir -p /home/${USERNAME}
69+
echo "export HTTP_PROXY=\"${HTTP_PROXY}\"" >> /home/${USERNAME}/.profile
70+
echo "export http_proxy=\"${HTTP_PROXY}\"" >> /home/${USERNAME}/.profile
71+
echo "export HTTPS_PROXY=\"${HTTPS_PROXY}\"" >> /home/${USERNAME}/.profile
72+
echo "export https_proxy=\"${HTTPS_PROXY}\"" >> /home/${USERNAME}/.profile
73+
echo "export FTP_PROXY=\"${FTP_PROXY}\"" >> /home/${USERNAME}/.profile
74+
echo "export ftp_proxy=\"${FTP_PROXY}\"" >> /home/${USERNAME}/.profile
75+
echo "export ALL_PROXY=\"${ALL_PROXY}\"" >> /home/${USERNAME}/.profile
76+
echo "export all_proxy=\"${ALL_PROXY}\"" >> /home/${USERNAME}/.profile
77+
echo "export NO_PROXY=\"${NO_PROXY}\"" >> /home/${USERNAME}/.profile
78+
echo "export no_proxy=\"${NO_PROXY}\"" >> /home/${USERNAME}/.profile
79+
80+
# # Apply common tools proxy settings for installed tools
81+
if [ "${CONFIGURE_GIT}" = "true" ]; then
82+
su -c "git config --global http.proxy ${HTTP_PROXY}" ${USERNAME}
83+
su -c "git config --global https.proxy ${HTTPS_PROXY}" ${USERNAME}
84+
git config --global http.proxy ${HTTP_PROXY}
85+
git config --global https.proxy ${HTTPS_PROXY}
86+
fi
87+
88+
echo "# Proxy settings" >> /etc/wgetrc
89+
echo "http_proxy=${HTTP_PROXY}" >> /etc/wgetrc
90+
echo "https_proxy=${HTTPS_PROXY}" >> /etc/wgetrc
91+
echo "ftp_proxy=${FTP_PROXY}" >> /etc/wgetrc
92+
echo "no_proxy=${NO_PROXY}" >> /etc/wgetrc
93+
echo "use_proxy=on" >> /etc/wgetrc
94+
95+
# enable root user to "apt-get" via proxy
96+
echo "Acquire::http::proxy \"${HTTP_PROXY}\";" >> /etc/apt/apt.conf
97+
echo "Acquire::https::proxy \"${HTTPS_PROXY}\";" >> /etc/apt/apt.conf
98+
fi
99+
100+
exit 0
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
# This file is maintained by velocitas CLI, do not modify manually. Change settings in .velocitas.json
3+
# Copyright (c) 2022 Robert Bosch GmbH and Microsoft Corporation
4+
#
5+
# This program and the accompanying materials are made available under the
6+
# terms of the Apache License, Version 2.0 which is available at
7+
# https://www.apache.org/licenses/LICENSE-2.0.
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12+
# License for the specific language governing permissions and limitations
13+
# under the License.
14+
#
15+
# SPDX-License-Identifier: Apache-2.0
16+
17+
echo "#######################################################"
18+
echo "### Checking container creation ###"
19+
echo "#######################################################"
20+
useradd vscode --password vscode -m
21+
usermod -aG sudo vscode
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
#!/bin/bash
2+
# This file is maintained by velocitas CLI, do not modify manually. Change settings in .velocitas.json
3+
# Copyright (c) 2022 Robert Bosch GmbH and Microsoft Corporation
4+
#
5+
# This program and the accompanying materials are made available under the
6+
# terms of the Apache License, Version 2.0 which is available at
7+
# https://www.apache.org/licenses/LICENSE-2.0.
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12+
# License for the specific language governing permissions and limitations
13+
# under the License.
14+
#
15+
# SPDX-License-Identifier: Apache-2.0
16+
17+
# restart Docker connection if in Codespaces
18+
# Workaround according to https://github.com/devcontainers/features/issues/671#issuecomment-1701754897
19+
if [ "${CODESPACES}" = "true" ]; then
20+
sudo pkill dockerd && sudo pkill containerd
21+
/usr/local/share/docker-init.sh
22+
fi
23+
24+
echo "#######################################################"
25+
echo "### Run VADF Lifecycle Management ###"
26+
echo "#######################################################"
27+
# needed to get rid of old leftovers
28+
sudo rm -rf ~/.velocitas
29+
velocitas init
30+
velocitas sync
31+
32+
echo "#######################################################"
33+
echo "### Install python requirements ###"
34+
echo "#######################################################"
35+
# Update pip before installing requirements
36+
pip3 install --upgrade pip
37+
REQUIREMENTS="./requirements.txt"
38+
if [ -f $REQUIREMENTS ]; then
39+
pip3 install -r $REQUIREMENTS
40+
fi
41+
REQUIREMENTS="./app/requirements-links.txt"
42+
if [ -f $REQUIREMENTS ]; then
43+
pip3 install -r $REQUIREMENTS
44+
fi
45+
# Dependencies for the app
46+
REQUIREMENTS="./app/requirements.txt"
47+
if [ -f $REQUIREMENTS ]; then
48+
pip3 install -r $REQUIREMENTS
49+
fi
50+
51+
# Dependencies for unit and integration tests
52+
REQUIREMENTS="./app/tests/requirements.txt"
53+
if [ -f $REQUIREMENTS ]; then
54+
pip3 install -r $REQUIREMENTS
55+
fi
56+
57+
# Add repo to git safe.directory
58+
REPO=$(pwd)
59+
git config --global --add safe.directory $REPO
60+
61+
# Add git name and email from env variables
62+
if [[ -n "${GIT_CONFIG_NAME}" && -n "${GIT_CONFIG_EMAIL}" ]]; then
63+
git config --global user.name $GIT_CONFIG_NAME
64+
git config --global user.email $GIT_CONFIG_EMAIL
65+
fi
66+
67+
68+
echo "#######################################################"
69+
echo "### VADF package status ###"
70+
echo "#######################################################"
71+
velocitas upgrade --dry-run
72+
73+
# Don't let container creation fail if lifecycle management fails
74+
echo "Done!"

0 commit comments

Comments
 (0)