1
0
Fork 0
mirror of https://github.com/MetaProvide/talked.git synced 2025-01-10 19:47:46 +00:00

Update development setup

This commit is contained in:
Magnus Walbeck 2021-08-06 14:13:41 +02:00
parent 285808d18a
commit 9bc71dd8d6
Signed by: mwalbeck
GPG key ID: CCB78CFF3F950769
9 changed files with 54 additions and 75 deletions

View file

@ -1,21 +0,0 @@
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.187.0/containers/ubuntu/.devcontainer/base.Dockerfile
# [Choice] Ubuntu version: bionic, focal
ARG VARIANT="focal"
FROM mcr.microsoft.com/vscode/devcontainers/base:0-${VARIANT}
ENV DEBIAN_FRONTEND=noninteractive
ENV POETRY_VIRTUALENVS_CREATE=false
# hadolint ignore=DL3013
RUN apt-get update; \
apt-get install -y --no-install-recommends \
python3 \
python3-pip \
firefox-geckodriver \
pulseaudio \
xvfb \
ffmpeg \
; \
pip3 install --no-cache-dir poetry; \
rm -rf /var/lib/apt/lists/*;

View file

@ -1,26 +0,0 @@
// 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.187.0/containers/ubuntu
{
"name": "Ubuntu",
"build": {
"dockerfile": "Dockerfile.vscode",
// Update 'VARIANT' to pick an Ubuntu version: focal, bionic
"args": {
"VARIANT": "focal"
}
},
// 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": [
"tamasfe.even-better-toml",
"ms-python.python",
"coenraads.bracket-pair-colorizer-2"
],
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],
// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "uname -a",
// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "vscode"
}

12
.editorconfig Normal file
View file

@ -0,0 +1,12 @@
root = true
[*]
indent_style = space
indent_size = 4
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
end_of_line = lf
[*.{yml,yaml,json}]
indent_size = 2

14
.vscode/extensions.json vendored Normal file
View file

@ -0,0 +1,14 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.
// Extension identifier format: ${publisher}.${name}. Example: vscode.csharp
// List of extensions which should be recommended for users of this workspace.
"recommendations": [
"editorconfig.editorconfig",
"ms-python.python"
],
// List of extensions recommended by VS Code that should not be recommended for users of this workspace.
"unwantedRecommendations": [
]
}

View file

@ -1,11 +1,5 @@
{
"editor.formatOnSave": true,
"[python]": {
"editor.tabSize": 4,
"editor.rulers": [
88
]
},
"python.linting.flake8Enabled": true,
"python.linting.enabled": true,
"python.formatting.provider": "black",

View file

@ -20,25 +20,17 @@ Call recording for Nextcloud Talk
## Dev setup
### VSCode
If you are using VSCode as your editor make sure you have the Remote - Containers plugin installed. You can find a link to the plugin [here](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) with instructions on how to install the required dependencies and how to use the plugin.
When the connection to the container has been setup run `poetry install` to install the required python dependencies and then you can run the program with `python3 talked/__init__.py`
### Generic
Make sure you have docker installed for your OS. Then build the generic docker container using this command
```
docker build . -f .devcontainer/Dockerfile.generic -t talked
docker build docker -f docker/Dockerfile.dev -t talked
```
Then start the container using this command, it will take over the current terminal you have open. The command will start the docker container giving you a bash shell and a user with the same ID as your user on the host. The root of this project will also be passthrough to the container in the /talked folder. The container will get removed when you exit out of it so you don't manually have to do it.
Then start the container using this command, it will take over the current terminal you have open. The command will start the docker container giving you a bash shell and a user with the same ID as your user on the host. The root of this project will also be passthrough to the container in the /home/talked/talked folder. The container will get removed when you exit out of it so you don't manually have to do it.
```
docker run --rm -it -v "$(pwd):/talked" talked
docker run --rm -it -v "$(pwd):/home/talked/talked" -e "UID=$(id -u)" -e "GID=$(id -g)" talked
```
When you enter the container you will be placed in the /talked folder, to get started first install the python dependencies using poetry.
When you enter the container you will be placed in the /home/talked/talked folder, to get started first install the python dependencies using poetry.
```
poetry install
```
@ -53,7 +45,8 @@ python3 talked/__init__.py
The last thing to do is create a file called `config.json` in the root of the project which contains a link to a public Nextcloud Talk room. Below you can see the boilerplate:
```
{
"call_link": ""
"call_link": "",
"log_level": 20
}
```

View file

@ -1,10 +1,12 @@
FROM ubuntu:20.04
ENV DEBIAN_FRONTEND=noninteractive
ENV POETRY_VIRTUALENVS_CREATE=false
ENV POETRY_VIRTUALENVS_IN_PROJECT=false
# hadolint ignore=DL3013
RUN set -ex; \
groupadd talked; \
useradd --shell /bin/bash --gid talked --create-home talked; \
apt-get update; \
apt-get install -y --no-install-recommends \
python3 \
@ -17,13 +19,14 @@ RUN set -ex; \
; \
pip3 install --no-cache-dir poetry; \
rm -rf /var/lib/apt/lists/*; \
mkdir /talked; \
chmod 777 /talked; \
groupadd --gid 1001 talked; \
useradd -s /bin/bash --uid 1000 --gid talked -m talked; \
echo talked ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/talked;
WORKDIR /talked
USER talked:talked
RUN set -ex; \
mkdir -p /home/talked/talked; \
chown talked:talked /home/talked/talked;
CMD [ "/bin/bash" ]
WORKDIR /home/talked/talked
COPY entrypoint.sh /entrypoint.sh
ENTRYPOINT [ "/entrypoint.sh" ]

10
docker/entrypoint.sh Executable file
View file

@ -0,0 +1,10 @@
#!/bin/sh
set -eu
UID=${UID:-1000}
GID=${GID:-1000}
usermod -o -u "$UID" talked
groupmod -o -g "$GID" talked
exec su talked

View file

@ -3,7 +3,7 @@ name = "talked"
version = "0.1.0"
description = "Call recording for Nextcloud Talk"
authors = ["Magnus Walbeck <mw@mwalbeck.org>"]
license = "AGPLv3-or-later"
license = "AGPL-3.0-or-later"
[tool.poetry.dependencies]
python = "^3.8"