From f72aa6e98d3686fd9f5322fc288eb8f5dc21beb2 Mon Sep 17 00:00:00 2001 From: Andrew Rioux Date: Sat, 6 May 2023 21:43:19 -0400 Subject: [PATCH] refactor: changed workflow to use Ubuntu replaced dev container Dockerfile with one which uses Ubuntu instead of Alpine. The Docker in Docker feature only works on Ubuntu, not Debian or Alpine, and the LLDB extension to enable debugging only supports Debian/Ubuntu --- .cargo/config.toml | 4 +-- .devcontainer/Dockerfile | 29 ----------------- .devcontainer/Dockerfile.alpine | 7 ++-- .devcontainer/Dockerfile.buster | 57 +++++++++++++++++++++++++++++++++ .devcontainer/devcontainer.json | 8 ++--- .vscode/launch.json | 7 ++++ Makefile.toml | 13 ++++++++ docker-compose.yml | 10 ++++++ 8 files changed, 94 insertions(+), 41 deletions(-) delete mode 100644 .devcontainer/Dockerfile create mode 100644 .devcontainer/Dockerfile.buster create mode 100644 Makefile.toml diff --git a/.cargo/config.toml b/.cargo/config.toml index c1ca86b..99afc80 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -1,2 +1,2 @@ -[build] -target = "x86_64-unknown-linux-musl" \ No newline at end of file +#[build] +#target = "x86_64-unknown-linux-musl" \ No newline at end of file diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile deleted file mode 100644 index 23fa621..0000000 --- a/.devcontainer/Dockerfile +++ /dev/null @@ -1,29 +0,0 @@ -# Copyright (C) 2023 Andrew Rioux -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . - -FROM rust:1-buster - -ENV DEBIAN_FRONTEND=noninteractive - -#apk add musl-dev openssl-dev docker-compose lldb && \ -RUN apt update && \ - apt install -y git cmake make automake autoconf libtool valgrind flex \ - linux-headers-5.10 bison docker-compose lldb libssl-dev libnl-3-dev sudo && \ - rustup component add clippy && \ - rustup target add x86_64-unknown-linux-musl && \ - useradd vscode && \ - mkdir -p /home/vscode && \ - chown -R vscode:vscode /home/vscode && \ - echo "vscode ALL=(ALL: ALL) NOPASSWD: ALL" >> /etc/sudoers \ No newline at end of file diff --git a/.devcontainer/Dockerfile.alpine b/.devcontainer/Dockerfile.alpine index 559d7dc..cd839f3 100644 --- a/.devcontainer/Dockerfile.alpine +++ b/.devcontainer/Dockerfile.alpine @@ -15,8 +15,5 @@ FROM rust:1-alpine -RUN apk add bash docker git cmake make automake musl-dev autoconf libtool valgrind \ - flex bison linux-headers openssl-dev apache2-utils docker-compose lldb && \ - rustup component add clippy && \ - mkdir /etc/docker && \ - echo '{ "storage-driver": "vfs" }' > /etc/docker/daemon.json \ No newline at end of file +RUN apk add cmake make automake musl-dev autoconf libtool \ + flex bison linux-headers openssl-dev lldb build-base \ No newline at end of file diff --git a/.devcontainer/Dockerfile.buster b/.devcontainer/Dockerfile.buster new file mode 100644 index 0000000..d2b5ac2 --- /dev/null +++ b/.devcontainer/Dockerfile.buster @@ -0,0 +1,57 @@ +# Copyright (C) 2023 Andrew Rioux +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +FROM ubuntu:22.04 + +ARG USERNAME=vscode + +ENV DEBIAN_FRONTEND=noninteractive \ + RUSTUP_HOME=/usr/local/rustup \ + CARGO_HOME=/usr/local/cargo \ + PATH=/usr/local/cargo/bin:$PATH:/home/vscode/.cargo/bin + +RUN apt-get update && \ + apt install -y git libtool valgrind docker-compose lldb sudo zsh wget && \ + apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/* && \ + adduser ${USERNAME} && \ + echo "$USERNAME ALL=(ALL:ALL) NOPASSWD: ALL" >> /etc/sudoers && \ + chsh -s /usr/bin/zsh ${USERNAME} && \ + wget https://static.rust-lang.org/rustup/archive/1.25.2/x86_64-unknown-linux-gnu/rustup-init && \ + echo "bb31eaf643926b2ee9f4d8d6fc0e2835e03c0a60f34d324048aa194f0b29a71c *rustup-init" | sha256sum -c - && \ + chmod +x rustup-init && \ + ./rustup-init -y --no-modify-path --profile minimal \ + --default-toolchain nightly --default-host x86_64-unknown-linux-gnu \ + --component rustfmt --component rust-src --component clippy && \ + rm rustup-init && \ + chmod -R a+w $RUSTUP_HOME $CARGO_HOME + +USER vscode + +RUN cargo install cargo-make + +#FROM rust:1-buster +# +#ENV DEBIAN_FRONTEND=noninteractive +# +#apk add musl-dev openssl-dev docker-compose lldb && \ +#RUN apt update && \ +# apt install -y git cmake make automake autoconf libtool valgrind flex musl-tools \ +# linux-headers-5.10 bison docker-compose lldb libssl-dev libnl-3-dev sudo && \ +# rustup component add clippy && \ +# rustup target add x86_64-unknown-linux-musl && \ +# useradd vscode && \ +# mkdir -p /home/vscode && \ +# chown -R vscode:vscode /home/vscode && \ +# echo "vscode ALL=(ALL: ALL) NOPASSWD: ALL" >> /etc/sudoers \ No newline at end of file diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 2cecd8b..da7865c 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,7 +1,7 @@ { "name": "sparse", "build": { - "dockerfile": "Dockerfile" + "dockerfile": "Dockerfile.buster" }, "customizations": { "vscode": { @@ -28,11 +28,9 @@ "--security-opt", "seccomp=unconfined" ], - "postStartCommand": "git submodule update --init", + "postStartCommand": "git submodule update --init && docker pull rust:1-alpine", "remoteUser": "vscode", "features": { - "ghcr.io/devcontainers/features/docker-in-docker": { - "dockerDashComposeVersion": "v2" - } + "ghcr.io/devcontainers/features/docker-in-docker": {} } } \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json index 33e9529..5419c5c 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -102,5 +102,12 @@ "args": [], "cwd": "${workspaceFolder}" }, + { + "name": "test launch", + "type": "lldb", + "request": "launch", + "program": "${workspaceFolder}/ex-bind-shell-backdoor", + "args": [] + } ] } \ No newline at end of file diff --git a/Makefile.toml b/Makefile.toml new file mode 100644 index 0000000..f4df978 --- /dev/null +++ b/Makefile.toml @@ -0,0 +1,13 @@ +[env] +CARGO_MAKE_EXTEND_WORKSPACE_MAKEFILE = true + +[config] +skip_core_tasks = true + +[tasks.default] +dependencies = ["build"] + +[tasks.build] +workspace = false +command = "docker-compose" +args = [ "run", "build", "${@}" ] \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 54748c2..06bd405 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,5 +1,15 @@ version: '3.8' services: + build: + build: + context: .devcontainer + dockerfile: Dockerfile.alpine + volumes: + - ${CARGO_HOME}/registry:${CARGO_HOME}/registry + - ${PWD}:/sparse + working_dir: /sparse + entrypoint: "/usr/local/cargo/bin/cargo build" + examples_bindshell_target: build: context: examples/secure-image