devcontainer server from scratch

This commit is contained in:
2025-06-07 10:20:28 +02:00
parent 613b8c6e34
commit e7ddfe9fcb
2 changed files with 24 additions and 16 deletions

View File

@@ -1,16 +1,30 @@
FROM mcr.microsoft.com/openjdk/jdk:21-ubuntu ARG VARIANT=21-jdk
FROM eclipse-temurin:${VARIANT}
# Set build arguments for username, UID, and GID RUN apt-get update \
ARG USERNAME=java && apt-get -y install --no-install-recommends \
ARG USER_UID=1000 ca-certificates \
ARG USER_GID=1000 git \
nano \
vim-tiny \
&& apt-get auto-remove -y \
&& apt-get clean -y \
&& chsh -s $(which bash) ubuntu \
&& echo 'export PS1="\e[01;32m\u\e[m:\e[01;34m\w\e[m\$ "' >> /home/ubuntu/.bashrc
# Create the user and group with the specified UID and GID ENV MAVEN_HOME=/opt/maven
RUN groupadd --gid $USER_GID $USERNAME \ ENV PATH=$MAVEN_HOME/bin:$PATH
&& useradd --uid $USER_UID --gid $USER_GID -m $USERNAME
ARG MAVEN_VERSION=3.9.10
ARG BASE_URL=https://dlcdn.apache.org/maven/maven-3/${MAVEN_VERSION}/binaries
RUN mkdir -p $MAVEN_HOME \
&& curl -fsSL -o /tmp/apache-maven.tar.gz ${BASE_URL}/apache-maven-${MAVEN_VERSION}-bin.tar.gz \
&& tar -xzf /tmp/apache-maven.tar.gz -C $MAVEN_HOME --strip-components=1 \
&& rm -f /tmp/apache-maven.tar.gz
# Set the default user # Set the default user
USER $USERNAME USER ubuntu
# Set the working directory # Set the working directory
WORKDIR /home/$USERNAME WORKDIR /home/ubuntu

View File

@@ -3,12 +3,6 @@
"build": { "build": {
"dockerfile": "Dockerfile", "dockerfile": "Dockerfile",
}, },
"features": {
"ghcr.io/devcontainers/features/java:1": {
"installMaven": "true"
},
"ghcr.io/devcontainers/features/git:1": {}
},
"containerEnv": { "containerEnv": {
"GIT_REPO_URL": "https://scm.vilanet.fr/kriss/slot" "GIT_REPO_URL": "https://scm.vilanet.fr/kriss/slot"
}, },