(breaking-change): this image will only work on podman now

Some adjustments to the mounts and launch options were made and now only works with podman
This commit is contained in:
Eduard Tolosa 2025-02-19 09:28:54 +00:00
parent 3fd4ac0ca5
commit 9e9826027b
2 changed files with 14 additions and 18 deletions

View file

@ -2,23 +2,19 @@ FROM rust:latest
# Install the development dependencies # 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 \ 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/* 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 # Install nightly toolchain and rustfmt for it and the stable version
RUN rustup toolchain install nightly --component rustfmt clippy && rustup component add rustfmt clippy \ 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 && 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 .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 # Detect the postgres version and set the volume
ENV POSTGRES_VERSION=15 ENV POSTGRES_VERSION=15
VOLUME /var/lib/postgresql/$POSTGRES_VERSION/main VOLUME /var/lib/postgresql/$POSTGRES_VERSION/main
# trust all local connections to postgres # trust all local connections to postgres
COPY configs/pg_hba.conf /etc/postgresql/$POSTGRES_VERSION/main/pg_hba.conf 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 # Allow the user to run sudo without password, generate locales and set the default one
USER root RUN echo "en_US.UTF-8 UTF-8" > /etc/locale.gen && locale-gen && update-locale
RUN echo "$USER_NAME ALL=(ALL:ALL) NOPASSWD: ALL" | tee /etc/sudoers.d/$USER_NAME && \ # Cool .bashrc
echo "en_US.UTF-8 UTF-8" > /etc/locale.gen && locale-gen && update-locale RUN cp /etc/skel/.bashrc /root/.bashrc
# Delete all the cargo cache and the apt cache # Delete all the cargo cache and the apt cache
RUN rm -rf /usr/local/cargo/registry && apt-get clean RUN rm -rf /usr/local/cargo/registry && apt-get clean

View file

@ -1,10 +1,11 @@
// This is intended to run **ONLY** on Podman
// This is the devcontainer.json file for the Rust development container // 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. // 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 // 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, // where you have all your Rust projects. You can however override the options,
// check the README.md for more information. // check the README.md for more information.
{ {
"name": "rust_devcontainer", "name": "rust_personal-devcontainer",
"build": { "build": {
"dockerfile": "Dockerfile" "dockerfile": "Dockerfile"
}, },
@ -28,26 +29,25 @@
] ]
} }
}, },
"workspaceFolder": "/home/vscode/workspace", "workspaceFolder": "/workspace",
"workspaceMount": "source=/var/local/development,target=/home/vscode/workspace,type=bind,consistency=cached", "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 // Handle CARGO_HOME=/usr/local/cargo creating a volume for the cargo data to persist between runs
"mounts": [ "mounts": [
{ {
"source": "cargo-cache-rust_devcontainer", "source": "cargo-cache-rust-personal_devcontainer",
"target": "/usr/local/cargo", "target": "/usr/local/cargo:U",
"type": "volume" "type": "volume"
}, },
// Handle the postgres data directory // Handle the postgres data directory
{ {
"source": "postgres-rust_devcontainer", "source": "postgres-rust-personal_devcontainer",
"target": "/var/lib/postgresql/15/main", "target": "/var/lib/postgresql/15/main:U",
"type": "volume" "type": "volume"
} }
], ],
"runArgs": [ "runArgs": [
"--restart=always", "--restart=always",
"--name=rust_devcontainer" "--name=rust_personal-devcontainer"
], ],
"postStartCommand": "sudo service postgresql start", "postStartCommand": "service postgresql start"
"remoteUser": "vscode"
} }