Skip to content

Commit d624ad2

Browse files
authored
Base image introduction to Python SDK Devcontainer (#57)
1 parent a513bec commit d624ad2

File tree

15 files changed

+79
-94
lines changed

15 files changed

+79
-94
lines changed

.devcontainer/Dockerfile

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2022 Robert Bosch GmbH and Microsoft Corporation
1+
# Copyright (c) 2022-2023 Robert Bosch GmbH and Microsoft Corporation
22
#
33
# This program and the accompanying materials are made available under the
44
# terms of the Apache License, Version 2.0 which is available at
@@ -12,7 +12,7 @@
1212
#
1313
# SPDX-License-Identifier: Apache-2.0
1414

15-
FROM ubuntu:20.04
15+
FROM ghcr.io/eclipse-velocitas/devcontainer-base-images/python:latest
1616

1717
# Force dapr to use localhost traffic
1818
ENV DAPR_HOST_IP="127.0.0.1"
@@ -21,19 +21,11 @@ ENV PATH=$PATH:/home/vscode/.dapr/bin
2121

2222
ENV DOCKER_BUILDKIT=1
2323

24-
# Fix for bug in devcontainer features
25-
ADD https://raw.githubusercontent.com/devcontainers/features/7fa90110d762797cc0b1c2fe8fcc028c9b813d56/src/common-utils/install.sh /tmp/scripts/install-common.sh
26-
RUN UID="4000" bash /tmp/scripts/install-common.sh
27-
ADD https://raw.githubusercontent.com/devcontainers/features/7fa90110d762797cc0b1c2fe8fcc028c9b813d56/src/docker-in-docker/install.sh /tmp/scripts/install-dind.sh
28-
RUN VERSION="20.10" bash /tmp/scripts/install-dind.sh
29-
3024
COPY scripts/*.sh /tmp/scripts/
3125
RUN find /tmp/scripts/ -type f -iname "*.sh" -exec chmod +x {} \;
3226
RUN /bin/bash /tmp/scripts/container-set.sh
3327
RUN /bin/bash /tmp/scripts/configure-proxies.sh
3428

35-
VOLUME [ "/var/lib/docker" ]
36-
3729
# Setting the ENTRYPOINT to docker-init.sh will start up the Docker Engine
3830
# inside the container "overrideCommand": false is set in devcontainer.json.
3931
# The script will also execute CMD if you need to alter startup behaviors.

.devcontainer/devcontainer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@
4545
],
4646
// Use 'forwardPorts' to make a list of ports inside the container available locally.
4747
// "forwardPorts": [],
48-
// Ensure Dapr is running on opening the container
49-
"postCreateCommand": "bash .devcontainer/scripts/postCreateCommand.sh",
48+
"onCreateCommand": "bash .devcontainer/scripts/postCreateCommand.sh",
5049
// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
5150
"remoteUser": "vscode"
5251
}

.devcontainer/scripts/add-python.sh

Lines changed: 0 additions & 33 deletions
This file was deleted.

.devcontainer/scripts/postCreateCommand.sh

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/bash
2-
# Copyright (c) 2022 Robert Bosch GmbH and Microsoft Corporation
2+
# Copyright (c) 2022-2023 Robert Bosch GmbH and Microsoft Corporation
33
#
44
# This program and the accompanying materials are made available under the
55
# terms of the Apache License, Version 2.0 which is available at
@@ -13,11 +13,6 @@
1313
#
1414
# SPDX-License-Identifier: Apache-2.0
1515

16-
echo "#######################################################"
17-
echo "### Executing add-python.sh ###"
18-
echo "#######################################################"
19-
.devcontainer/scripts/add-python.sh 2>&1 | tee -a $HOME/add-python.log
20-
2116
echo "#######################################################"
2217
echo "### Install python requirements ###"
2318
echo "#######################################################"

.pre-commit-config.yaml

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -113,27 +113,27 @@ repos:
113113
.*_pb2_grpc.py
114114
)$
115115
116-
- repo: https://github.com/Lucas-C/pre-commit-hooks
117-
rev: v1.3.1
118-
hooks:
119-
- id: insert-license
120-
files: '.*\.(py|pyi|yaml|yml|sh|helmignore|dockerignore|gitignore)$'
121-
args:
122-
- --license-filepath
123-
- license_header.txt
124-
- --comment-style
125-
- "#"
126-
- id: insert-license
127-
files: '.*\.(proto)$'
128-
args:
129-
- --license-filepath
130-
- license_header.txt
131-
- --comment-style
132-
- //
133-
- id: insert-license
134-
files: "Dockerfile.*"
135-
args:
136-
- --license-filepath
137-
- license_header.txt
138-
- --comment-style
139-
- "#"
116+
# - repo: https://github.com/Lucas-C/pre-commit-hooks
117+
# rev: v1.3.1
118+
# hooks:
119+
# - id: insert-license
120+
# files: '.*\.(py|pyi|yaml|yml|sh|helmignore|dockerignore|gitignore)$'
121+
# args:
122+
# - --license-filepath
123+
# - license_header.txt
124+
# - --comment-style
125+
# - "#"
126+
# - id: insert-license
127+
# files: '.*\.(proto)$'
128+
# args:
129+
# - --license-filepath
130+
# - license_header.txt
131+
# - --comment-style
132+
# - //
133+
# - id: insert-license
134+
# files: "Dockerfile.*"
135+
# args:
136+
# - --license-filepath
137+
# - license_header.txt
138+
# - --comment-style
139+
# - "#"

.vscode/scripts/run-vehicledatabroker.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/bash
2-
# Copyright (c) 2022 Robert Bosch GmbH and Microsoft Corporation
2+
# Copyright (c) 2022-2023 Robert Bosch GmbH and Microsoft Corporation
33
#
44
# This program and the accompanying materials are made available under the
55
# terms of the Apache License, Version 2.0 which is available at
@@ -31,7 +31,7 @@ if [[ `uname -m` == 'aarch64' || `uname -m` == 'arm64' ]]; then
3131
echo "Detected ARM architecture"
3232
PROCESSOR="aarch64"
3333
DATABROKER_BINARY_NAME="databroker_aarch64.tar.gz"
34-
DATABROKER_EXEC_PATH="$DATABROKER_ASSET_FOLDER/$PROCESSOR/target/aarch64-unknown-linux-gnu/release"
34+
DATABROKER_EXEC_PATH="$DATABROKER_ASSET_FOLDER/$PROCESSOR/target/release"
3535
else
3636
echo "Detected x86_64 architecture"
3737
PROCESSOR="x86_64"

NOTICE-3RD-PARTY-CONTENT.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
|pathspec|0.10.2|Mozilla Public License 2.0 (MPL 2.0)|
5252
|pbr|5.11.0|Apache 2.0|
5353
|pep517|0.13.0|MIT|
54-
|pip|23.0|MIT|
54+
|pip|23.0.1|MIT|
5555
|pip-tools|6.11.0|BSD|
5656
|platformdirs|2.6.0|MIT|
5757
|pluggy|1.0.0|MIT|

examples/array-datatype/src/main.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2022 Robert Bosch GmbH and Microsoft Corporation
1+
# Copyright (c) 2022-2023 Robert Bosch GmbH and Microsoft Corporation
22
#
33
# This program and the accompanying materials are made available under the
44
# terms of the Apache License, Version 2.0 which is available at
@@ -16,6 +16,7 @@
1616

1717
import asyncio
1818
import logging
19+
import signal
1920

2021
from vehicle_model.sample import Vehicle, vehicle
2122

@@ -55,4 +56,7 @@ async def main():
5556
await array.run()
5657

5758

58-
asyncio.run(main())
59+
LOOP = asyncio.get_event_loop()
60+
LOOP.add_signal_handler(signal.SIGTERM, LOOP.stop)
61+
LOOP.run_until_complete(main())
62+
LOOP.close()

examples/atomic-set/src/main.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2022 Robert Bosch GmbH and Microsoft Corporation
1+
# Copyright (c) 2022-2023 Robert Bosch GmbH and Microsoft Corporation
22
#
33
# This program and the accompanying materials are made available under the
44
# terms of the Apache License, Version 2.0 which is available at
@@ -15,6 +15,7 @@
1515
import asyncio
1616
import json
1717
import logging
18+
import signal
1819

1920
from sdv_model import Vehicle, vehicle
2021

@@ -81,4 +82,7 @@ async def main():
8182
await example.run()
8283

8384

84-
asyncio.run(main())
85+
LOOP = asyncio.get_event_loop()
86+
LOOP.add_signal_handler(signal.SIGTERM, LOOP.stop)
87+
LOOP.run_until_complete(main())
88+
LOOP.close()

examples/datapoint-set/src/main.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2022 Robert Bosch GmbH and Microsoft Corporation
1+
# Copyright (c) 2022-2023 Robert Bosch GmbH and Microsoft Corporation
22
#
33
# This program and the accompanying materials are made available under the
44
# terms of the Apache License, Version 2.0 which is available at
@@ -15,6 +15,7 @@
1515
import asyncio
1616
import json
1717
import logging
18+
import signal
1819

1920
from sdv_model import Vehicle, vehicle
2021

@@ -92,4 +93,7 @@ async def main():
9293
await example.run()
9394

9495

95-
asyncio.run(main())
96+
LOOP = asyncio.get_event_loop()
97+
LOOP.add_signal_handler(signal.SIGTERM, LOOP.stop)
98+
LOOP.run_until_complete(main())
99+
LOOP.close()

0 commit comments

Comments
 (0)