-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create build, dev, daemon docker compose workflows for easy developme…
…nt on any system (with docker) VSCode development container attempt to not mess with file endings Allow running with debugging as module Add docker workflow documentation start and VSCode remote container config enable docker container development environment split vscode image into seperate image only start VSCode container for dev env
- Loading branch information
Showing
11 changed files
with
233 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at: | ||
// https://github.com/microsoft/vscode-dev-containers/tree/v0.191.1/containers/docker-existing-docker-compose | ||
// If you want to run as a non-root user in the container, see .devcontainer/docker-compose.yml. | ||
{ | ||
"name": "Existing Docker Compose (Extend)", | ||
|
||
// Update the 'dockerComposeFile' list if you have more compose files or use different names. | ||
// The .devcontainer/docker-compose.yml file contains any overrides you need/want to make. | ||
"dockerComposeFile": [ | ||
"../docker-compose.yml", | ||
"docker-compose.yml" | ||
], | ||
|
||
// The 'service' property is the name of the service for the container that VS Code should | ||
// use. Update this value and .devcontainer/docker-compose.yml to the real service name. | ||
"service": "vscode", | ||
|
||
"runServices": ["vscode"], | ||
|
||
// The optional 'workspaceFolder' property is the path VS Code should open by default when | ||
// connected. This is typically a file mount in .devcontainer/docker-compose.yml | ||
"workspaceFolder": "/workspace", | ||
|
||
// Set *default* container specific settings.json values on container create. | ||
"settings": {}, | ||
|
||
// Add the IDs of extensions you want installed when the container is created. | ||
"extensions": [ | ||
"ms-python.python", | ||
"lextudio.restructuredtext", | ||
"trond-snekvik.simple-rst", | ||
"ms-azuretools.vscode-docker" | ||
], | ||
"portsAttributes": { | ||
"80": { | ||
"label": "HTTP_API" | ||
} | ||
}, | ||
|
||
// Use 'forwardPorts' to make a list of ports inside the container available locally. | ||
// "forwardPorts": [], | ||
|
||
// Uncomment the next line if you want start specific services in your Docker Compose config. | ||
// "runServices": [], | ||
|
||
// Uncomment the next line if you want to keep your containers running after VS Code shuts down. | ||
// "shutdownAction": "none", | ||
|
||
// Uncomment the next line to run commands after the container is created - for example installing curl. | ||
"postCreateCommand": "sudo python3 setup.py develop && sudo chmod o+rw /var/run/docker.sock", | ||
|
||
// Uncomment to connect as a non-root user if you've added one. See https://aka.ms/vscode-remote/containers/non-root. | ||
"remoteUser": "vscode" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
version: '3.7' | ||
services: | ||
# Update this to the name of the service you want to work with in your docker-compose.yml file | ||
vscode: | ||
# If you want add a non-root user to your Dockerfile, you can use the "remoteUser" | ||
# property in devcontainer.json to cause VS Code its sub-processes (terminals, tasks, | ||
# debugging) to execute as the user. Uncomment the next line if you want the entire | ||
# container to run as this user instead. Note that, on Linux, you may need to | ||
# ensure the UID and GID of the container user you create matches your local user. | ||
# See https://aka.ms/vscode-remote/containers/non-root for details. | ||
# | ||
# user: vscode | ||
|
||
# Uncomment if you want to override the service's Dockerfile to one in the .devcontainer | ||
# folder. Note that the path of the Dockerfile and context is relative to the *primary* | ||
# docker-compose.yml file (the first in the devcontainer.json "dockerComposeFile" | ||
# array). The sample below assumes your primary file is in the root of your project. | ||
# | ||
image: hiveeyes/vscode:latest | ||
build: | ||
context: . | ||
dockerfile: .devcontainer/vscode.dockerfile | ||
|
||
volumes: | ||
# Update this to wherever you want VS Code to mount the folder of your project | ||
- .:/workspace:cached | ||
|
||
# Uncomment the next line to use Docker from inside the container. See https://aka.ms/vscode-remote/samples/docker-from-docker-compose for details. | ||
- /var/run/docker.sock:/var/run/docker.sock | ||
|
||
# Uncomment the next four lines if you will use a ptrace-based debugger like C++, Go, and Rust. | ||
# cap_add: | ||
# - SYS_PTRACE | ||
# security_opt: | ||
# - seccomp:unconfined | ||
|
||
# Overrides default command so things don't shut down after the process ends. | ||
command: /bin/sh -c "while sleep 1000; do :; done" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Must build the normal dev image first! | ||
FROM hiveeyes/dev:latest | ||
|
||
ARG USERNAME=vscode | ||
ARG USER_UID=1000 | ||
ARG USER_GID=$USER_UID | ||
|
||
# Create the non-root user | ||
RUN groupadd --gid $USER_GID $USERNAME \ | ||
&& useradd --uid $USER_UID --gid $USER_GID -m $USERNAME \ | ||
# | ||
# [Optional] Add sudo support. Omit if you don't need to install software after connecting. | ||
&& apt-get update \ | ||
&& apt-get install -y sudo \ | ||
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \ | ||
&& chmod 0440 /etc/sudoers.d/$USERNAME | ||
|
||
# Make Python3.9 the default python (since some extension us /usr/bin/python3) | ||
RUN ln -f -s /usr/local/bin/python3 /usr/bin/python3 && \ | ||
python3 -m pip install -U sphinx rstcheck snooty | ||
|
||
# Add docker CLI tools | ||
COPY --from=docker:dind /usr/local/bin/docker /usr/local/bin/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
* text=auto eol=lf | ||
*.{cmd,[cC][mM][dD]} text eol=crlf | ||
*.{bat,[bB][aA][tT]} text eol=crlf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,3 +22,4 @@ presets.mk | |
.coverage | ||
/spikes | ||
/doc/build | ||
_build/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# https://github.com/pycom/pycom-libraries/tree/master/pycom-docker-fw-build | ||
|
||
FROM debian:buster-slim | ||
|
||
RUN apt-get update && \ | ||
apt-get install -y python3 python3-pip && \ | ||
apt-get -y clean && \ | ||
python3 -m pip install -U pip setuptools | ||
|
||
# ADD requirements-cpython.txt /tmp/build/requirements.txt | ||
# RUN python3 -m pip install -r /tmp/build/requirements.txt | ||
|
||
ADD dist/terkin*-py3-none-any.whl /tmp/build/ | ||
RUN python3 -m pip install /tmp/build/*.whl | ||
|
||
WORKDIR /opt/terkin-datalogger | ||
CMD [ "terkin", "--config=settings.py", "--daemon"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
############################## | ||
Docker Development Environment | ||
############################## | ||
|
||
|
||
************* | ||
Prerequisites | ||
************* | ||
You must have the Docker CLI tools and access to a Docker Host. to check this use::: | ||
|
||
docker system info | ||
git clone https://github.com/hiveeyes/terkin-datalogger.git | ||
cd terkin-datalogger | ||
|
||
|
||
********************** | ||
Prepare working images | ||
********************** | ||
Use `docker compose` to build images::: | ||
|
||
docker compose build | ||
|
||
Use `docker compose` to build terkin packge wheels:: | ||
|
||
# This will generate python wheels in the `dist` folder. | ||
docker compose up build | ||
|
||
|
||
************* | ||
Configuration | ||
************* | ||
Create configuration from blueprint::: | ||
|
||
cp src/settings.raspberrypi-basic.py src/settings.py | ||
|
||
|
||
*** | ||
Run | ||
*** | ||
Run terkin-datalogger as a daemon within a docker compose service::: | ||
|
||
docker compose up daemon | ||
# Or in headless mode: | ||
docker compose up -d daemon | ||
|
||
*********************** | ||
VSCode Remote Container | ||
*********************** | ||
You can use the `dev` container as a basis for a VSCode remote Development Environment. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -105,3 +105,6 @@ def start_ui(self): | |
|
||
finally: | ||
ui.stop() | ||
|
||
if __name__ == "__main__": | ||
cli() |