Skip to content

Commit

Permalink
Merge pull request #667 from tira-io/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
mam10eks authored Sep 24, 2024
2 parents 93f508f + 23d835d commit 445abd9
Show file tree
Hide file tree
Showing 511 changed files with 24,212 additions and 45,546 deletions.
15 changes: 0 additions & 15 deletions .devcontainer.json

This file was deleted.

92 changes: 92 additions & 0 deletions .devcontainer/Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
FROM ubuntu:24.04

ENV TZ=Europe/Berlin
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

RUN apt-get update && apt-get install -y sudo git locales
RUN echo "en_US.UTF-8 UTF-8" | tee -a /etc/locale.gen && locale-gen

########################################################################################################################
# Create Users #
########################################################################################################################
RUN <<EOF
# Create docker group for later
addgroup docker

# Change root Password to 1234
echo 'root:1234' | chpasswd

# Create new user: "dev" also with password 1234
useradd -ms /bin/bash dev
echo 'dev:1234' | chpasswd
usermod -aG sudo dev
usermod -aG docker dev
EOF


########################################################################################################################
# Frontend #
########################################################################################################################
USER root

RUN <<EOF
apt-get update
apt-get install -y npm
npm install --global yarn
EOF




########################################################################################################################
# Backend (Application) #
########################################################################################################################
ENV PIP_BREAK_SYSTEM_PACKAGES 1
USER root
RUN apt-get update && apt-get install -y python3 python3-pip python3-dev pkg-config default-libmysqlclient-dev \
libpcre3-dev

# Environment Variables for TIRA Configuration:
ENV TIRA_ROOT=/workspaces/tira/model/src
ENV TIRA_CONFIG=/workspaces/tira/application/config/tira-application-config.yml
ENV TIRA_DEBUG=true
ENV DISCOURSE_API_KEY="I am so secret"

########################################################################################################################
# Client #
########################################################################################################################
USER root
RUN <<EOF
# Install Java (some dependencies like python are already installed by the application module)
apt-get update
apt-get install -y openjdk-11-jdk
# Install Docker and set correct permissions to the docker.sock
apt-get install -y curl
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg
chmod a+r /etc/apt/keyrings/docker.gpg
echo \
"deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
"$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \
tee /etc/apt/sources.list.d/docker.list > /dev/null
apt-get update -y
apt-get install -y docker-ce-cli
touch /var/run/docker.sock
chown root:docker /var/run/docker.sock
EOF



########################################################################################################################
# Documentation #
########################################################################################################################
ENV PIP_BREAK_SYSTEM_PACKAGES 1
USER root
RUN apt-get update && apt-get install -y python3 python3-pip pkg-config plantuml wget
# Install umlet
RUN mkdir -p /usr/share/umlet \
&& cd /usr/share/umlet \
&& wget https://www.umlet.com/download/umlet_15_1/umlet-standalone-15.1.zip -O download.zip \
&& cd /usr/share/umlet \
&& unzip download.zip
USER dev
RUN pip3 install sphinx furo myst-parser sphinx-toolbox sphinx-design sphinxcontrib-plantuml sphinxcontrib-umlet
152 changes: 152 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/docker-existing-docker-compose
{
"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.dev.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": "devenv",

// 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": "/workspaces/${localWorkspaceFolderBasename}",

// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},

// Use 'forwardPorts' to make a list of ports inside the container available locally.
"forwardPorts": [
"nginx:8080",
"nginx:8081",
"nginx:8082"
],

"portsAttributes": {
"nginx:8080": {
"label": "TIRA Backend",
"protocol": "https"
},
"nginx:8081": {
"label": "Authentication",
"protocol": "https"
},
"nginx:8082": {
"label": "TIRA Frontend",
"protocol": "https"
}
},

// 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.
"postCreateCommand": "cd frontend; yarn; cd ../python-client; pip install -e .[test,dev]; cd ../application/; pip install -e .[test,dev]; make setup; make import-mock-data",

// Configure tool-specific properties.
"customizations": {
"vscode": {
"settings": {
"editor.formatOnSave": true,
"json.format.keepLines": true,
"livePreview.portNumber": 3080,
"remote.autoForwardPorts": false,
"files.exclude": {
"**/__pycache__": true,
"**/.mypy_cache": true,
"**/.pytest_cache": true,
"**/*.egg-info": true,
"**/node_modules": true,
"application/.data-dumps": true
},
"launch": {
"version": "0.2.0",
"configurations": [
{
"name": "TIRA Frontend",
"type": "node",
"request": "launch",
"runtimeExecutable": "yarn",
"cwd": "${workspaceFolder:Frontend}/",
"runtimeArgs": [
"dev"
]
},
{
"name": "TIRA Backend",
"type": "debugpy",
"request": "launch",
"args": [
"run_develop"
],
"django": true,
"autoStartBrowser": false,
"program": "${workspaceFolder:Backend}/src/manage.py"
},
{
"name": "TIRA Backend Tests",
"type": "debugpy",
"request": "launch",
"program": "${workspaceFolder:Backend}/src/manage.py",
"cwd": "${workspaceFolder:Backend}/test",
"args": [ "test", "--failfast", "--settings=settings_test" ],
"django": true,
"env": { "PYTHONPATH": ":../src:.", "DJANGO_SETTINGS_MODULE": "settings_test" },
"justMyCode": false
},
{
"name": "Frontend Tests",
"type": "node",
"request": "launch",
"runtimeExecutable": "yarn",
"args": [ "test" ],
"cwd": "${workspaceFolder:Frontend}"
}
],
"compounds": [
{
"name": "TIRA Stack",
"configurations": [
"TIRA Backend",
"TIRA Frontend"
],
"stopAll": true
}
]
},
"[python]": {
"editor.codeActionsOnSave": { "source.organizeImports": "explicit" }
},
"python.formatting.provider": "black",
"isort.args": [ "--profile", "black" ]
},
"extensions": [
"Vue.volar",
"ms-vscode.live-server",
"ms-python.python",
"ms-python.isort",
"ms-python.black-formatter",
"ms-python.flake8",
"ms-python.mypy-type-checker",
"42Crunch.vscode-openapi",
"vuetifyjs.vuetify-vscode"
]
}
},

// Uncomment to connect as an existing user other than the container default. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "devcontainer"

// Needed for parts of the python-client that build and run docker containers
"privileged": true,
"mounts": [ "source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind" ]
}
13 changes: 13 additions & 0 deletions .devcontainer/devfiles/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
This folder contains files that are **only** relevant for setting up a mock environment for development. The subfolder
`authelia` contains an customized
[configuration file](https://github.com/authelia/authelia/blob/v4.38.8/config.template.yml) for
[Authelia](https://www.authelia.com/) and a user database containing some mock users and admins. The configuration files
for the reverse proxy (inside `nginx`) are copied with only slight modifications from Authelia's
[Guide](https://www.authelia.com/integration/proxies/nginx/) and the certificates are self-signed since we need https
for the auth provider (Authelia) to be happy.

If the certificates expired, you can run
```sh
sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout tira-dev-selfsigned.key -out tira-dev-selfsigned.crt
```
to generate new ones.
Loading

0 comments on commit 445abd9

Please sign in to comment.