Skip to content

Commit 382e930

Browse files
committed
initial commit
1 parent cfb89d1 commit 382e930

File tree

8 files changed

+120
-0
lines changed

8 files changed

+120
-0
lines changed

.devcontainer/.dockerignore

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
.dockerignore
2+
.env
3+
.git
4+
.gitignore
5+
.vs
6+
.vscode
7+
docker-compose.yml
8+
docker-compose.*.yml
9+
*.class

.devcontainer/Dockerfile

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
FROM openjdk:17.0.1-bullseye
2+
# To check for newer JDK versions, see https://openjdk.java.net/, then
3+
# https://hub.docker.com/_/openjdk. Last check on 16 jan 2022 [Manfred, 16jan2022]
4+
5+
RUN apt-get update && \
6+
apt-get upgrade -y && \
7+
apt-get install -y \
8+
procps \
9+
iputils-ping \
10+
net-tools \
11+
lsb-release
12+
# procps: to support command 'ps'
13+
# iputils-ping: to support command 'ping' (https://linuxconfig.org/ping-command-not-found-on-ubuntu-20-04-focal-fossa-linux) [Manfred, 19sep2021]
14+
# net-tools: to support command such as 'arp', 'ifconfig', 'netstat', etc. (https://helpmanual.io/packages/apt/net-tools/) [Manfred, 26sep2021]
15+
# lsb-release: to support commmand 'lsb_release -a' [Manfred, 15jan2022]
16+
# You can safely remove the packages you don't want. [Manfred, 08oct2021]
17+
18+
# Create non-root user (zero trust principle, least privileged principle)
19+
RUN groupadd -g 1000 -r dev && \
20+
useradd -u 1000 -r -g dev -m -s $(which bash) dev
21+
# Option '-m' to create home directory (see https://askubuntu.com/a/393470)
22+
# Option '-s' to set shell for this user (see comment in https://askubuntu.com/a/393470)
23+
# Option '-r' creates a system user which does not expire (see https://linuxize.com/post/how-to-create-users-in-linux-using-the-useradd-command/)
24+
25+
# How to add sudo support for the non-root user is described at https://code.visualstudio.com/remote/advancedcontainers/add-nonroot-user#_creating-a-nonroot-user
26+
# However, standard practice is not to add sudo support for security reasons. VS Code will connect
27+
# to the running dev container as the user specified in file ".devcontainer/devcontainer.json" in
28+
# property "remoteUser". If you need to run commands as root to set up the dev container, use the
29+
# "RUN" directive in Dockerfile or add suitable code to the script ".devcontainer/entrypoint.sh".
30+
# [Manfred, 16jan2022]
31+
32+
# Create working directory. Ownership will be changed in entrypoint.sh which
33+
# executes *after* the volume has been mounted.
34+
RUN mkdir /src
35+
36+
# Copy entrypoint script into container, make it executable, then make it the entrypoint for the
37+
# container:
38+
COPY entrypoint.sh /entrypoint.sh
39+
RUN chmod +x /entrypoint.sh
40+
# Option '+x' adds executable flag to the file
41+
ENTRYPOINT ["/entrypoint.sh"]

.devcontainer/devcontainer.json

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"name": "java-dev",
3+
"dockerComposeFile": [
4+
"docker-compose.yml"
5+
],
6+
"service": "java-dev",
7+
"workspaceFolder": "/src",
8+
"extensions": [
9+
"eamodio.gitlens",
10+
"editorconfig.editorconfig",
11+
"shd101wyy.markdown-preview-enhanced",
12+
"vscjava.vscode-java-pack"
13+
],
14+
"remoteUser": "dev",
15+
"shutdownAction": "stopCompose"
16+
}

.devcontainer/docker-compose.yml

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
version: '3.7'
2+
3+
services:
4+
java-dev:
5+
container_name: java-dev
6+
hostname: java-dev.local
7+
build:
8+
context: .
9+
working_dir: /src
10+
volumes:
11+
- ..:/src:cached
12+
command: >
13+
bash -c "sleep infinity"
14+
networks:
15+
rimutec:
16+
17+
networks:
18+
rimutec:

.devcontainer/entrypoint.sh

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/sh
2+
3+
echo Running entrypoint.sh
4+
5+
#################################################################################################################
6+
# Provided the Dockerfile doesn't change the user, this script will run as 'root'. However, once VS Code connects
7+
# it will connect remotely as user 'dev' [Manfred, 19sep2021]
8+
9+
10+
#################################################################################################################
11+
# Change ownership of all directories and files in the mounted volume:
12+
chown -R dev:dev /src
13+
# Option '-R' applies the ownerhip change recursively on files and directories in /src
14+
15+
16+
#################################################################################################################
17+
# Finally invoke what has been specified as CMD in Dockerfile or command in docker-compose:
18+
"$@"

.editorconfig

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# top-most EditorConfig file
2+
root = true
3+
4+
# Unix-style newlines with a newline ending every file
5+
[*]
6+
end_of_line = lf
7+
indent_style = space
8+
indent_size = 3
9+
insert_final_newline = true
10+
# Do not add the following without confirming that nullable warnings and errors are still honored
11+
# generated_code = true

.env

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Name of the project so that services specified in docker-compose for this project
2+
# are grouped under that name in Docker Desktop:
3+
COMPOSE_PROJECT_NAME=rimutec

.gitattributes

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Ensure all files git considers to be text to have normalized (LF) line endings in the repository
2+
# https://stackoverflow.com/a/33890199/411428
3+
# [Manfred, 19sep2021]
4+
* text=auto

0 commit comments

Comments
 (0)