Copyright (c) 2023, Greg PFISTER. MIT License
This is a simple Ubuntu container to use as development environment for Docker projects.
This is image is provided with Ubuntu 22.04.
See version mapping to find out which version Ubuntu and node and java.
This image is built from ghcr.io/gp-devenv/gp-base-devenv.
The image can be found here.
In order to persist user data, a volume for the /home folder is set. The root user will not be persisted.
Volume | Description |
---|---|
/home | Persist the user data stored in their home folder |
Image version contains the Ubuntu version and the build version, using the
format <Ubuntu version>-<Build version>
. The build version refers to the
latest Dockerfile script, when modification consists of fixing (patch change),
or adding or removing something significant (minor change) or breaking (major).
For example:
Image | Description |
---|---|
ghcr.io/gp-devenv/gp-docker-devenv:22.04-1 | The latest build 1.x using Ubuntu 22.04 |
ghcr.io/gp-devenv/gp-docker-devenv:22.04-1.1 | The latest build 1.1.x using Ubuntu 22.04 |
ghcr.io/gp-devenv/gp-docker-devenv:22.04-1.1.0 | The latest build 1.1.0 using Ubuntu 22.04 |
ghcr.io/gp-devenv/gp-docker-devenv:22.04-1.0 | The latest build 1.0.x using Ubuntu 22.04 |
ghcr.io/gp-devenv/gp-docker-devenv:22.04-1.0.0 | The latest build 1.0.0 using Ubuntu 22.04 |
For CI/CD, the build version is store in .version
file. The build version is
in the format
SemVer.
Only the latest version (MAJOR, MAJOR.MINOR and MAJOR.MINOR.PATCH) is been built daily.
When you are making change to the image, use :develop at the end of the
build, run and scan commands. The *-dev
tag
should never be pushed...
In order to build x-platform, docker buildx
must be enabled (more info
here). Then, instead of
build
command, buildx
command should be used (for example:
npm run buildx:develop
will create a cross-platform image tagged develop
).
You will need to create a multiarch builder:
./src/scripts/buildx/setup.sh
On successful completion, it should at least have platforms linux/arm64
,
linux/arm/v7
and linux/amd64
:
[+] Building 5.8s (1/1) FINISHED
=> [internal] booting buildkit 5.8s
=> => pulling image moby/buildkit:buildx-stable-1 7s
=> => creating container buildx_buildkit_multiarch0 1s
Name: multiarch
Driver: docker-container
Nodes:
Name: multiarch0
Endpoint: unix:///var/run/docker.sock
Status: running
Platforms: linux/arm64, linux/amd64, linux/amd64/v2, linux/riscv64,
linux/ppc64le, linux/s390x, linux/386, linux/mips64le, linux/mips64,
linux/arm/v7, linux/arm/v6
Once the previous step is completed, simpy run to build the current version:
(cd src && ./scripts/buildx/build.sh)
To build using a specific Ubuntu version, use:
(cd scr && ./scripts/dev/image/build.sh <UBUNTU_VERSION>)
where UBUNTU_VERSION
must 22.04.
It will create and image ghcr.io/gp-devenv/gp-docker-devenv
tagged with the current
version (see src/.version
file) and -dev
suffix.
You may alter the .src/.version
file should you want to have different tags or
names, however if you PR your change, it will be rejected. The ideal solution
is to run the docker build
command instead.
To remove the created image (named:
ghcr.io/gp-devenv/gp-docker-devenv:<UBUNTU_VERIONS>-<VERSION>-dev
), simply use:
(cd scr && ./scripts/dev/image/rm.sh <UBUNTU_VERSION>)
To run an interactive container of a give Ubuntu version, simple use:
(cd src && ./scripts/dev/container/run.sh <UBUNTU_VERSION>)
where UBUNTU_VERSION
must 22.04.
Alternatively, you can create and start a container to run in background, and execute scripts on this container, using the following scripts:
Action | Script |
---|---|
create | (cd src && ./scripts/dev/container/create.sh <UBUNTU_VERSION>) |
start | (cd src && ./scripts/dev/container/start.sh <UBUNTU_VERSION>) |
stop | (cd src && ./scripts/dev/container/stop.sh <UBUNTU_VERSION>) |
exec | (cd src && ./scripts/dev/container/exec.sh <UBUNTU_VERSION>) <COMMAND> |
To remove the created container (named:
gp-docker-devenv:<UBUNTU_VERIONS>-<VERSION>-dev
), simply use:
(cd src && ./scripts/dev/container/rm.sh <UBUNTU_VERSION>)
To scan the image of a give Ubuntu version, simple use:
(cd src && ./scripts/dev/scan.sh <UBUNTU_VERSION>)
where UBUNTU_VERSION
must be 22.04.
Should you want to make other changes, the ideal solution is to build from this image. For example, here's the way to set the image to a different timezone than "Europe/Paris" (the default one):
FROM ghcr.io/gp-devenv/gp-docker-devenv:22.04
ENV TZ="America/New_York"
# Switch to root
USER root
# Reconfigure tzdata
RUN dpkg-reconfigure -f noninteractive tzdata
# Switch back to vscode
USER vscode
Important: unless you really want to use the root user, you should always
make sure the vscode
is the last one activate.
Base image version
correspond to the underlying base image that can be found
here
Image | Base image version | Ubuntu | amd64 | arm64 | arm/v7 | Daily build |
---|---|---|---|---|---|---|
22:04-1.x | ghcr.io/gp-devenv/gp-base-devenv:22.04-1 | 22.04 (LTS) | X | X | X | Yes |
You will have to build from this image to disable the
the password less sudo command. Typically create a Dockerfile
like:
FROM ghcr.io/gp-devenv/gp-docker-devenv:22.04
ARG VSCODE_PASSWORD="dummy"
# Switch to root to make changes
USER root
# Remove the specific config for sudo and add to sudo group
RUN rm /etc/sudoers.d/vscode && \
usermod -aG sudo vscode
# Change the password.
RUN usermod -p $VSCODE_PASSWORD vscode
# Switch back to vscode
USER vscode
If you simply want to get rid of sudo
:
FROM ghcr.io/gp-devenv/gp-docker-devenv:22.04
# Switch to root to make changes
USER root
# Remove the specific config for sudo and add to sudo group
RUN rm /etc/sudoers.d/vscode && \
apt-get purge -y sudo
# Switch back to vscode
USER vscode
There will be one soon !!! Add notification to this project so that when the update on this file is done you can check.
See known issues here.
See instructions here.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
See license here.