Merge pull request 'Improved dev container' (#3) from improve_dev_env into main

Reviewed-on: http://ivt5wiimhwpo56td6eodn2n3fduug3bglqvqewbk2jnyl4hcimea.b32.i2p/git/git/Larra/larra/pulls/3
This commit is contained in:
sha512sum 2024-09-25 18:33:29 +00:00
commit 50751a7c8a
7 changed files with 84 additions and 26 deletions

View file

@ -13,6 +13,14 @@ RUN useradd -ms /bin/bash dev \
&& echo "dev ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers.d/dev \
&& chmod 0440 /etc/sudoers.d/dev
# Add docker and docker-compose and add permissions to run without sudo
COPY --from=library/docker:latest /usr/local/bin/docker /usr/bin/docker
COPY --from=docker/compose:latest /usr/local/bin/docker-compose /usr/bin/docker-compose
RUN groupadd docker &&\
usermod -aG docker dev &&\
newgrp docker
# Add the custom bash prompt with branch info
RUN printf '\n\
function modify_prompt { \n\

View file

@ -1,8 +1,15 @@
{
"name": "Arch Linux with GCC & Clang++",
"build": {
"dockerfile": "Dockerfile"
},
"dockerComposeFile": "docker-compose.yml",
"service": "devcontainer",
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",
"forwardPorts": [
5222,
5269,
5280,
5443
],
"postStartCommand": "/workspaces/larra/.devcontainer/post_create_config.sh",
"customizations": {
"vscode": {
"extensions": [

View file

@ -0,0 +1,39 @@
services:
devcontainer:
build:
context: .
dockerfile: Dockerfile
# Required for ptrace-based debuggers like C++, Go, and Rust
cap_add:
- SYS_PTRACE
security_opt:
- seccomp:unconfined
volumes:
- ../..:/workspaces/:cached
- /var/run/docker.sock:/var/run/docker.sock:ro
network_mode: service:ejabberd_server # To access ejabberd inside a devcontainer
command: sleep infinity # To keep container alive
depends_on:
- ejabberd_server
ejabberd_server:
image: ghcr.io/processone/ejabberd
container_name: ejabberd
#
# For some reasons below environment variables doesn't work inside vs code dev container
# Please, use devcontainer.json 'postStartCommand' for configuring ejabberd_server
#
environment:
- CTL_ON_CREATE=register admin localhost admin ;
register test1 localhost test1 ;
- CTL_ON_START=registered_users localhost ;
status
ports:
- "5222:5222"
- "5269:5269"
- "5280:5280"
- "5443:5443"
volumes:
- ./ejabberd.yml:/opt/ejabberd/conf/ejabberd.yml:ro

View file

@ -37,7 +37,7 @@ listen:
max_stanza_size: 262144
shaper: c2s_shaper
access: c2s
starttls_required: true
starttls_required: false
-
port: 5223
ip: "::"

View file

@ -0,0 +1,10 @@
sleep 1
printf "\n\n\tConfigure ejabber server\n\n"
sudo docker exec -it ejabberd ejabberdctl register admin localhost admin
sudo docker exec -it ejabberd ejabberdctl register sha512sum localhost 12345
printf "\n\n\tList of registered users:\n"
sudo docker exec -it ejabberd ejabberdctl registered_users localhost
printf "\n\n\tConfigurating ejabber server ended\n\n"

19
.vscode/tasks.json vendored
View file

@ -3,6 +3,20 @@
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "Ejabberd: show logs",
"type": "shell",
"command": [
"sudo docker exec -it ejabberd tail -f logs/ejabberd.log"
]
},
{
"label": "Ejabberd: open shell",
"type": "shell",
"command": [
"sudo docker exec -it ejabberd sh"
]
},
{
"label": "Build Debug GCC",
"type": "shell",
@ -14,8 +28,7 @@
"|| ( printf '\n\n\t\\e[31mERROR: Build failed!\\e[0m\n\n\n' && exit 1 )"
],
"options": {
"env": {
}
"env": {}
},
"presentation": {
"clear": true
@ -39,7 +52,7 @@
"options": {
"env": {
"CC": "/usr/sbin/clang",
"CXX": "/usr/sbin/clang++",
"CXX": "/usr/sbin/clang++"
}
},
"presentation": {

View file

@ -1,19 +0,0 @@
version: '3.7'
services:
ejabberd_server:
image: ghcr.io/processone/ejabberd
container_name: ejabberd
environment:
- CTL_ON_CREATE=register admin localhost admin ;
register user localhost password
- CTL_ON_START=registered_users localhost ;
status
ports:
- "5222:5222"
- "5269:5269"
- "5280:5280"
- "5443:5443"
volumes:
- ./ejabberd.yml:/opt/ejabberd/conf/ejabberd.yml:ro