Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

devcontainer added #163

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// For format details, see https://containers.dev/implementors/json_reference/
{
"name": "Java Developer Container",
"build": {
"dockerfile": "../Dockerfile",
"target": "developer"
},
"customizations": {
"vscode": {
// Set *default* container specific settings.json values on container create.
"settings": {},
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"ms-python.python",
"vscjava.vscode-java-pack",
"vmware.vscode-boot-dev-pack",
"github.vscode-github-actions",
"redhat.vscode-yaml",
"ms-azuretools.vscode-docker"
]
}
},
"features": {
// Some default things like git config
"ghcr.io/devcontainers/features/common-utils:2": {
"upgradePackages": false
}
},
"runArgs": [
// Allow the container to access the host X11 display and EPICS CA
"--net=host",
jacomago marked this conversation as resolved.
Show resolved Hide resolved
// Make sure SELinux does not disable with access to host filesystems like tmp
"--security-opt=label=disable",
// Mount the user sockets folder
"-v${localEnv:XDG_RUNTIME_DIR}:${localEnv:XDG_RUNTIME_DIR}",
// add the docker socket environment variable to the container
"-e=DOCKER_HOST=${localEnv:DOCKER_HOST}"
],
// Mount the parent as /workspaces so we can pip install peers as editable
"workspaceMount": "source=${localWorkspaceFolder}/..,target=/workspaces,type=bind",
// for rootless we must not to mess with user ids inside the container
"updateRemoteUserUID": false,
// for rootless we are root inside the container
"remoteUser": "root"
}
41 changes: 38 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,41 @@
FROM eclipse-temurin:17-jre
# Stage 1: Development stage
FROM eclipse-temurin:17-jdk AS developer

# deployment unit
COPY target/ChannelFinder-*.jar /channelfinder/ChannelFinder-*.jar
ENV DOCKER=docker-27.3.1

# Install Maven and Git for development purposes
RUN apt-get update && \
apt-get install -y maven git && \
apt-get clean

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will want docker as well for running the testcontainers based integration tests.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, I haven't worked with testcontainers before. I think the docker-in-docker would use the host docker through a socket.

Or rather 'podman in podman' for the DLS users.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really want to approve without knowing the following command passes in a devcontainer:

mvn clean install test-compile failsafe:integration-test failsafe:verify --batch-mode --fail-at-end -Djacoco.skip=true -DskipITs=false -DskipITCoverage=true

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will test this

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in which instance would you like to run this?

I could drop it here instead of line 23 in Dockerfile

RUN mvn clean install

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok so theoretically the docker executable is now available inside the developer container. still elastic search connection refused. investigating

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

docker: Cannot connect to the Docker daemon at unix:///run/user/1225263/podman/podman.sock. Is the docker daemon running?.
See 'docker run --help'.```

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I installed podman but it refuses to run as root

maybe I need to add something about a new user into devcontainer or Dockerfile

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trying to pull quay.io/podman/hello:latest...
Getting image source signatures
Copying blob 81df7ff16254 done   | 
Copying config 5dd467fce5 done   | 
Writing manifest to image destination
ERRO[0013] Unmounting /var/lib/containers/storage/overlay/6ab302e27a11f20f53d9a2ade9743629b9350af8447449a7acc145ff153eca20/merged: invalid argument 
ERRO[0013] Preparing container 4969dcf74b9acdebf49a1f5004e14b630a68b43570231bead1b8df5ed30bda3f: netavark: setns: IO error: Operation not permitted (os error 1) 
Error: mounting storage for container 4969dcf74b9acdebf49a1f5004e14b630a68b43570231bead1b8df5ed30bda3f: creating overlay mount to /var/lib/containers/storage/overlay/6ab302e27a11f20f53d9a2ade9743629b9350af8447449a7acc145ff153eca20/merged, mount_data="lowerdir=/var/lib/containers/storage/overlay/l/XUJMKUCC4OWTZV3Q5QEPVLUMDN,upperdir=/var/lib/containers/storage/overlay/6ab302e27a11f20f53d9a2ade9743629b9350af8447449a7acc145ff153eca20/diff,workdir=/var/lib/containers/storage/overlay/6ab302e27a11f20f53d9a2ade9743629b9350af8447449a7acc145ff153eca20/work": using mount program /usr/bin/fuse-overlayfs: unknown argument ignored: lazytime
fuse: device not found, try 'modprobe fuse' first
fuse-overlayfs: cannot mount: No such file or directory
: exit status 1

I tried parametrizing the remoteUser (comment it out), but it's still as root

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

even podman pull does not quite work as expected

podman pull docker.elastic.co/elasticsearch/elasticsearch:8.16.1
Trying to pull docker.elastic.co/elasticsearch/elasticsearch:8.16.1...
Getting image source signatures
Copying blob 4ca545ee6d5d done   | 
Copying blob e7894aa63b6b done   | 
Copying blob fc92672f5fb7 done   | 
Copying blob deb9b088b6a9 done   | 
Copying blob d06b22f717ef done   | 
Copying blob 9ab872b2449e done   | 
Copying blob 533fb8518242 done   | 
Copying blob 17672f99d9ac done   | 
Copying blob 7936da0b8295 done   | 
Copying blob f4101ba1f689 done   | 
Error: copying system image from manifest list: writing blob: adding layer with blob "sha256:e7894aa63b6b441f711d543f0bd9f3584e66c7aac167b2f7ceac4bab2a89ca48": processing tar file(potentially insufficient UIDs or GIDs available in user namespace (requested 0:42 for /etc/gshadow): Check /etc/subuid and /etc/subgid if configured locally and run "podman system migrate": lchown /etc/gshadow: invalid argument): exit status 1


# install the docker ce cli binary
RUN curl -O https://download.docker.com/linux/static/stable/x86_64/${DOCKER}.tgz && \
tar xvf ${DOCKER}.tgz && \
cp docker/docker /usr/bin && \
rm -r ${DOCKER}.tgz docker

# Set the working directory for development
WORKDIR /workspace

# Optionally, start an interactive shell for development
CMD ["/bin/bash"]

# Stage 2: Build stage
FROM developer as builder

# Copy the application code from the developer workspace or local context
COPY . /workspace
WORKDIR /workspace

# Run Maven to clean and build the application JAR
RUN mvn clean install

# Stage 3: Production deployment stage
FROM eclipse-temurin:17-jre AS production

# Copy only the built JAR from the builder stage
COPY --from=builder /workspace/target/ChannelFinder-*.jar /channelfinder/ChannelFinder-*.jar

# Set the CMD to run the application in production mode
CMD ["java", "-jar", "/channelfinder/ChannelFinder-*.jar", "--spring.config.name=application"]
Loading