Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .devcontainer/Dockerfile

This file was deleted.

31 changes: 0 additions & 31 deletions .devcontainer/devcontainer.json

This file was deleted.

9 changes: 9 additions & 0 deletions .devcontainer/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM mcr.microsoft.com/devcontainers/rust:bullseye
RUN apt-get update && apt-get -y install pkg-config libssl-dev libxml2-dev libclang-dev
RUN apt update && \
apt install sudo && \
usermod -aG sudo vscode && \
echo "%sudo ALL=(ALL) NOPASSWD:ALL" | tee -a /etc/sudoers > /dev/null

RUN chown vscode:vscode -R /home/vscode
USER vscode
39 changes: 39 additions & 0 deletions .devcontainer/docker/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"name": "xhandler-rust",
"build": {
"dockerfile": "Dockerfile"
},
"runArgs": [
"--privileged",
"--userns=keep-id"
],
"remoteUser": "vscode",
"features": {
"ghcr.io/devcontainers/features/rust:1": {},
"ghcr.io/devcontainers/features/node:1": {
"version": "20"
},
"ghcr.io/devcontainers/features/docker-in-docker:2": {}
},
"postCreateCommand": "bash .devcontainer/docker/postCreateCommand.sh",
"customizations": {
"jetbrains": {
"backend": "RustRover"
},
"vscode": {
"settings": {},
"extensions": [
"vadimcn.vscode-lldb",
"rust-lang.rust-analyzer",
"tamasfe.even-better-toml",
"github.vscode-github-actions",
"github.vscode-pull-request-github"
]
},
"codespaces": {
"openFiles": [
"README.md"
]
}
}
}
2 changes: 2 additions & 0 deletions .devcontainer/podman/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
REPO_PATH=/home/cferiavi/git/openubl/xhandler-rust
USER_UID=115091
37 changes: 37 additions & 0 deletions .devcontainer/podman/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
FROM quay.io/fedora/fedora:41

ARG USERNAME=vscode
ARG USER_UID=1000
ARG USER_GID=$USER_UID

COPY entrypoint.sh /entrypoint.sh

RUN dnf -y update && \
dnf install -y @development-tools && \
dnf install -y curl wget podman

RUN groupadd --gid $USER_GID $USERNAME && \
useradd --uid $USER_UID --gid $USER_GID -m $USERNAME && \
echo $USERNAME:10000:5000 > /etc/subuid && echo $USERNAME:10000:5000 > /etc/subgid && \
# Allow user to execute 'sudo' without password
usermod -aG wheel $USERNAME && \
echo "%wheel ALL=(ALL) NOPASSWD:ALL" | tee -a /etc/sudoers > /dev/null

# Podman
# https://github.com/containers/podman/issues/2788#issuecomment-479923274
RUN chmod 4755 /usr/bin/newgidmap && chmod 4755 /usr/bin/newuidmap

# set permissions
RUN chown $USERNAME:$USERNAME -R /home/$USERNAME

RUN usermod -aG wheel $USERNAME && \
# Allow user to execute 'sudo' without password
echo "%wheel ALL=(ALL) NOPASSWD:ALL" | tee -a /etc/sudoers > /dev/null && \
# https://github.com/containers/podman/issues/2788#issuecomment-479923274
chmod 4755 /usr/bin/newgidmap && chmod 4755 /usr/bin/newuidmap

ENV _CONTAINERS_USERNS_CONFIGURED=""

ENTRYPOINT [ "/entrypoint.sh" ]
USER $USERNAME
CMD ["tail", "-f", "/dev/null"]
24 changes: 24 additions & 0 deletions .devcontainer/podman/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "xhandler-rust",
"dockerComposeFile": "docker-compose.yml",
"overrideCommand": true,
"shutdownAction": "stopCompose",
"service": "xhandler-rust",
"remoteUser": "vscode",
"onCreateCommand": "bash .devcontainer/podman/onCreateCommand.sh",
"postCreateCommand": "bash .devcontainer/podman/postCreateCommand.sh",
"customizations": {
"jetbrains": {
"backend": "RustRover"
},
"vscode": {
"extensions": [
"vadimcn.vscode-lldb",
"rust-lang.rust-analyzer",
"tamasfe.even-better-toml",
"github.vscode-github-actions",
"github.vscode-pull-request-github"
]
}
}
}
18 changes: 18 additions & 0 deletions .devcontainer/podman/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
volumes:
cargo-cache:

services:
xhandler-rust:
# https://github.com/microsoft/vscode-remote-release/issues/10215
image: localhost/xhandler-rust_devcontainer-xhandler-rust:latest
build:
context: .
dockerfile: ./Dockerfile
args:
USER_UID: ${USER_UID}
privileged: true
userns_mode: "keep-id"
# command: tail -f /dev/null
volumes:
- ${REPO_PATH}:/workspace:cached
- cargo-cache:/home/vscode/.cargo
20 changes: 20 additions & 0 deletions .devcontainer/podman/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/sh

# Ensure $HOME exists when starting
if [ ! -d "${HOME}" ]; then
mkdir -p "${HOME}"
fi

# Setup $PS1 for a consistent and reasonable prompt
if [ -w "${HOME}" ] && [ ! -f "${HOME}"/.bashrc ]; then
echo "PS1='\s-\v \w \$ '" > "${HOME}"/.bashrc
fi

# Add current (arbitrary) user to /etc/passwd and /etc/group
if ! whoami > /dev/null 2>&1; then
if [ -w /etc/passwd ]; then
echo "update passwd file"
echo "${USER_NAME:-user}:x:$(id -u):0:${USER_NAME:-user} user:${HOME}:/bin/bash" >> /etc/passwd
echo "${USER_NAME:-user}:x:$(id -u):" >> /etc/group
fi
fi
8 changes: 8 additions & 0 deletions .devcontainer/podman/onCreateCommand.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
sudo dnf install -y @development-tools
sudo dnf install -y @c-development
sudo dnf install -y libxml2-devel openssl-devel gcc gcc-c++ cmake perl

sudo dnf install -y rustup
rustup-init -y
. "$HOME/.cargo/env"
rustup update
2 changes: 2 additions & 0 deletions .devcontainer/podman/postCreateCommand.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Git autocomplete
echo "source /usr/share/bash-completion/completions/git" >> ~/.bashrc
2 changes: 1 addition & 1 deletion .github/actions/install-dependencies/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ runs:
- name: Install dependencies
shell: bash
run: |
sudo apt-get -y install pkg-config xmlsec1 libxml2-dev libxmlsec1-dev libxmlsec1-openssl libclang-dev
sudo apt-get -y install pkg-config libssl-dev libxml2-dev libclang-dev
Loading
Loading