diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 9f36b1a..9fd5884 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -2,23 +2,19 @@ FROM rust:latest # Install the development dependencies RUN apt-get update && apt-get upgrade -y && apt-get install -y build-essential curl git libssl-dev pkg-config make postgresql-client \ postgresql clang lld sudo vim bash-completion && apt-get clean && rm -rf /var/lib/apt/lists/* -# Create a non-root user -ENV USER_NAME=vscode -RUN useradd -m $USER_NAME -s /bin/bash -USER $USER_NAME # Install nightly toolchain and rustfmt for it and the stable version RUN rustup toolchain install nightly --component rustfmt clippy && rustup component add rustfmt clippy \ && cargo install diesel_cli cargo-edit cargo-update cargo-audit cargo-udeps && mkdir -p /home/$USER_NAME/workspace # Copy .bash_aliases, it contains several useful aliases for cargo -COPY configs/.bash_aliases /home/$USER_NAME/.bash_aliases +COPY configs/.bash_aliases /root/.bash_aliases # Detect the postgres version and set the volume ENV POSTGRES_VERSION=15 VOLUME /var/lib/postgresql/$POSTGRES_VERSION/main # trust all local connections to postgres COPY configs/pg_hba.conf /etc/postgresql/$POSTGRES_VERSION/main/pg_hba.conf # Allow the user to run sudo without password, generate locales and set the default one -USER root -RUN echo "$USER_NAME ALL=(ALL:ALL) NOPASSWD: ALL" | tee /etc/sudoers.d/$USER_NAME && \ - echo "en_US.UTF-8 UTF-8" > /etc/locale.gen && locale-gen && update-locale +RUN echo "en_US.UTF-8 UTF-8" > /etc/locale.gen && locale-gen && update-locale +# Cool .bashrc +RUN cp /etc/skel/.bashrc /root/.bashrc # Delete all the cargo cache and the apt cache RUN rm -rf /usr/local/cargo/registry && apt-get clean diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 44b7066..7022c93 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,10 +1,11 @@ +// This is intended to run **ONLY** on Podman // This is the devcontainer.json file for the Rust development container // It's intended to be used for many different projects, so it's a bit more generic. // All you need is to create a symlink to /var/local/development from the directory // where you have all your Rust projects. You can however override the options, // check the README.md for more information. { - "name": "rust_devcontainer", + "name": "rust_personal-devcontainer", "build": { "dockerfile": "Dockerfile" }, @@ -28,26 +29,25 @@ ] } }, - "workspaceFolder": "/home/vscode/workspace", - "workspaceMount": "source=/var/local/development,target=/home/vscode/workspace,type=bind,consistency=cached", + "workspaceFolder": "/workspace", + "workspaceMount": "source=/var/local/personal-development,target=/workspace,type=bind,consistency=cached", // Handle CARGO_HOME=/usr/local/cargo creating a volume for the cargo data to persist between runs "mounts": [ { - "source": "cargo-cache-rust_devcontainer", - "target": "/usr/local/cargo", + "source": "cargo-cache-rust-personal_devcontainer", + "target": "/usr/local/cargo:U", "type": "volume" }, // Handle the postgres data directory { - "source": "postgres-rust_devcontainer", - "target": "/var/lib/postgresql/15/main", + "source": "postgres-rust-personal_devcontainer", + "target": "/var/lib/postgresql/15/main:U", "type": "volume" } ], "runArgs": [ "--restart=always", - "--name=rust_devcontainer" + "--name=rust_personal-devcontainer" ], - "postStartCommand": "sudo service postgresql start", - "remoteUser": "vscode" + "postStartCommand": "service postgresql start" } \ No newline at end of file