-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from shirzartenwer/docker_container
First docker devcontainer is running
- Loading branch information
Showing
5 changed files
with
296 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
FROM mcr.microsoft.com/devcontainers/cpp:1-ubuntu-24.04 | ||
# Another option would be use the offical image from ubuntu, # Use the official Ubuntu base image | ||
#FROM ubuntu:latest | ||
|
||
ARG REINSTALL_CMAKE_VERSION_FROM_SOURCE="ubuntu-24.04" | ||
|
||
# Set environment variables (optional but good practice) | ||
ENV DEBIAN_FRONTEND=noninteractive | ||
# This env is for it to work on mac | ||
ENV VCPKG_FORCE_SYSTEM_BINARIES=1 | ||
|
||
# Update the Ubuntu package list and install necessary packages | ||
RUN apt-get update && apt-get upgrade -y && \ | ||
apt-get install -y \ | ||
autoconf \ | ||
automake \ | ||
autoconf-archive \ | ||
build-essential \ | ||
ca-certificates \ | ||
coreutils \ | ||
bash \ | ||
cmake \ | ||
ccache \ | ||
cppcheck \ | ||
curl \ | ||
debianutils \ | ||
dialog \ | ||
diffutils \ | ||
dirmngr \ | ||
doxygen \ | ||
dpkg \ | ||
e2fsprogs \ | ||
git \ | ||
git-man \ | ||
gnupg \ | ||
gnupg-l10n \ | ||
gnupg-utils \ | ||
gnupg2 \ | ||
gpg \ | ||
gpg-agent \ | ||
gpg-wks-client \ | ||
gpg-wks-server \ | ||
gpgconf \ | ||
gpgsm \ | ||
gpgv \ | ||
groff-base \ | ||
gzip \ | ||
htop \ | ||
iproute2 \ | ||
jq \ | ||
libtool \ | ||
icu-devtools \ | ||
libpng-dev \ | ||
libzip-dev \ | ||
locales \ | ||
login \ | ||
lua5.4\ | ||
lsof \ | ||
media-types \ | ||
mount \ | ||
mold \ | ||
nano \ | ||
ninja-build \ | ||
ncdu \ | ||
netbase \ | ||
openssh-client \ | ||
openssl \ | ||
passwd \ | ||
psmisc \ | ||
python3 \ | ||
python3-minimal \ | ||
readline-common \ | ||
rsync \ | ||
sed \ | ||
strace \ | ||
sudo \ | ||
sysvinit-utils \ | ||
sqlite3 \ | ||
sqlite3-tools \ | ||
tar \ | ||
tzdata \ | ||
unzip \ | ||
util-linux \ | ||
vim-common \ | ||
vim-tiny \ | ||
wget \ | ||
xxd \ | ||
zip \ | ||
&& apt-get clean && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
# # Clean up | ||
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* | ||
|
||
# Set timezone (optional) | ||
RUN ln -fs /usr/share/zoneinfo/Europe/Zurich /etc/localtime && dpkg-reconfigure -f noninteractive tzdata | ||
|
||
# Create a user with sudo privileges (optional) | ||
RUN useradd -ms /bin/bash dockeruser && echo "dockeruser:password" | chpasswd && adduser dockeruser sudo | ||
|
||
# Set the default user (optional) | ||
USER dockeruser | ||
|
||
# Set the default working directory | ||
WORKDIR /home/dockeruser | ||
|
||
# Expose port 22 for SSH (if needed) | ||
EXPOSE 22 | ||
|
||
# Entry point (optional, depends on use case) | ||
CMD [ "bash" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
Tools needed to dev and build WorkHorz (mandatory) | ||
|
||
## Oct 16th Version | ||
|
||
Ubuntu OS >= 24.04 (soon 24.10) | ||
GCC >= 14.1 (soon 14.2) | ||
Standard: C++23 (soon C++26) | ||
MoLD >= 2.30 (linker) | ||
Ninja >= 1.11.1 (builder) | ||
CMake >= 3.28 | ||
CCache >= 4.9.1 (compiler cache) | ||
DOxygen >= 1.9.8 (documentation generator) | ||
vcpkg (newest) | ||
bash | ||
lua5.4 (package Ubuntu) | ||
cppCheck >= 2.13 | ||
OpenSSL >= 3.0.13 | ||
SQLite >= 3.44 | ||
|
||
Installing newer version of GCC on Ubunutu | ||
|
||
Explained here: https://www.dedicatedcore.com/blog/install-gcc-compiler-ubuntu/ | ||
|
||
Autoconf tools: | ||
autoconf >= 2.71 | ||
automake >= 1.16.5 | ||
autoconf-archive >= 20220903-3 | ||
Autotools | ||
ICU: | ||
libicu74 >= 74.2 | ||
icu-devtools | ||
libtool (for libsodium at least) | ||
PNG: libpng-dev | ||
libzip | ||
liblzma | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// For format details, see https://aka.ms/devcontainer.json. For config options, see the | ||
// README at: https://github.com/devcontainers/templates/tree/main/src/cpp | ||
{ | ||
"name": "WorkHorz developer", | ||
"build": { | ||
"dockerfile": "Dockerfile" | ||
}, | ||
// Things in the feature are installed as VScode extentions within the container | ||
"features": { | ||
"ghcr.io/warrenbuckley/codespace-features/sqlite:1": {} | ||
}, | ||
"customizations": { | ||
"vscode": { | ||
"extensions": [ | ||
"ms-vscode.cpptools", | ||
"ms-vscode.cmake-tools", | ||
"ms-vscode.vscode-ssh", | ||
"twxs.cmake" | ||
], | ||
"settings": { | ||
"C_Cpp.default.compilerPath": "/usr/bin/gcc-14", | ||
"C_Cpp.intelliSenseEngine": "default", | ||
"terminal.integrated.shell.linux": "/bin/bash", | ||
"terminal.integrated.profiles.windows": { | ||
"WSL": { | ||
"path": "C:\\Windows\\System32\\wsl.exe", | ||
"args": [] | ||
} | ||
} | ||
|
||
} | ||
} | ||
}, | ||
|
||
// 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": [], | ||
|
||
// Use 'postCreateCommand' to run commands after the container is created. | ||
"postCreateCommand": "sudo bash ./.devcontainer/startup_script.sh" | ||
|
||
// Configure tool-specific properties. | ||
// "customizations": {}, | ||
|
||
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. | ||
// "remoteUser": "root" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
{ | ||
"name": "WorkHorz Dev Container", | ||
"image": "mcr.microsoft.com/devcontainers/base:ubuntu", | ||
"context": ".", | ||
"dockerFile": "Dockerfile_whz.txt", | ||
"settings": { | ||
"C_Cpp.default.compilerPath": "/usr/bin/gcc-14", | ||
"C_Cpp.intelliSenseEngine": "Default", | ||
"terminal.integrated.shell.linux": "/bin/bash", | ||
"terminal.integrated.profiles.windows": { | ||
"WSL": { | ||
"path": "C:\\Windows\\System32\\wsl.exe", | ||
"args": [] | ||
} | ||
}, | ||
"remote.WSL2.connectionMethod": "wslExeProxy" | ||
}, | ||
"extensions": [ | ||
"ms-vscode.cpptools", | ||
"ms-vscode.cmake-tools", | ||
"ms-vscode.vscode-ssh", | ||
"twxs.cmake" | ||
], | ||
"forwardPorts": [22], | ||
"postCreateCommand": "cmake -B build -S . -G Ninja", | ||
"remoteUser": "dockeruser", | ||
"features": { | ||
"ghcr.io/devcontainers/features/ccache:1": {}, | ||
"ghcr.io/devcontainers/features/gcc:14": {}, | ||
"ghcr.io/devcontainers/features/mold:2": {}, | ||
"ghcr.io/devcontainers/features/ninja:1": {}, | ||
"ghcr.io/devcontainers/features/cmake:3.28": {} | ||
} | ||
} | ||
|
||
# TODO:[ | ||
|
||
1. Get all packages for Linux directly from APT with specified version. | ||
2. Find Mac specific settings for VScode in container and add it | ||
|
||
] | ||
|
||
# Nov. 7th 2024 | ||
|
||
## TODO | ||
1. A shell script that takes care of: | ||
- fetch the vcpkag diretory | ||
- go there and run the boot-strap.sh | ||
- do a sudo git pull in that directory | ||
Done :) | ||
|
||
~2. A github secret to store the dockeruser password. Make sure it doesn't need the password everytime.~ | ||
I skipped this because I figured out it's not needed and I didn't encounter permission error anymore. | ||
|
||
3. Set GCC as default complier - check the article sent by Patrick |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#!/bin/bash | ||
|
||
set -euo pipefail | ||
set -x | ||
trap 'echo "Error occurred at line $LINENO while executing: $BASH_COMMAND"; exit 1' ERR | ||
|
||
echo "Starting the vcpkg startup script..." | ||
|
||
# Find the full path to vcpkg | ||
VCPKG_PATH="/usr/local/vcpkg/vcpkg" | ||
|
||
if [ -z "$VCPKG_PATH" ]; then | ||
echo "Error: vcpkg is not installed or not in PATH." | ||
exit 5 | ||
fi | ||
echo "Found vcpkg at: $VCPKG_PATH" | ||
|
||
# Extract the directory from the path | ||
VCPKG_DIR=$(dirname "$VCPKG_PATH") | ||
|
||
if [ ! -d "$VCPKG_DIR" ]; then | ||
echo "Error: vcpkg directory '$VCPKG_DIR' not found!" | ||
exit 11 | ||
fi | ||
echo "Switching to vcpkg directory: $VCPKG_DIR" | ||
cd "$VCPKG_DIR" | ||
|
||
if [ ! -f "./bootstrap-vcpkg.sh" ]; then | ||
echo "Error: bootstrap-vcpkg.sh not found!" | ||
exit 111 | ||
fi | ||
|
||
echo "Running bootstrap-vcpkg.sh..." | ||
./bootstrap-vcpkg.sh | ||
|
||
if [ ! -d ".git" ]; then | ||
echo "Error: Not a Git repository!" | ||
exit 1111 | ||
fi | ||
|
||
echo "Updating vcpkg repository..." | ||
git config --global --add safe.directory "$VCPKG_DIR" | ||
git pull | ||
|
||
echo "Everything in the startup script ran successfully!" |