Skip to content

Add .copy-files file which copies over files from /home/tooling to /h… - #228

Closed
dkwon17 wants to merge 1 commit into
devfile:mainfrom
dkwon17:copy-files
Closed

Add .copy-files file which copies over files from /home/tooling to /h…#228
dkwon17 wants to merge 1 commit into
devfile:mainfrom
dkwon17:copy-files

Conversation

@dkwon17

@dkwon17 dkwon17 commented Aug 6, 2025

Copy link
Copy Markdown
Collaborator

…ome/user in the entrypoint

This PR is an upstream equivalent of this PR: https://github.com/redhat-developer/devspaces-images/pull/770

For https://issues.redhat.com/browse/CRW-8598 and https://issues.redhat.com/browse/CRW-8932

To test this PR:

Build the base image:

$ cd base/ubi9 && DOCKER_BUILDKIT=1 docker image build --progress=plain -t <BASE_IMAGE> .

Create these 4 empty files:

.
└── some-directory/
    ├── config
    ├── config2
    ├── case1.Dockerfile
    └── case2.Dockerfile
Case 1: Testing CRW-8932

Put the following into case1.Dockerfile:

FROM <BASE_IMAGE>

RUN mkdir -p /home/tooling/.config/test

COPY config2 /home/tooling/.config/test/
COPY config /home/tooling/.config/

USER root
RUN chmod 777 /home/tooling/.config/test/config2 /home/tooling/.config/config

USER 1001

Build the image:

docker build -t quay.io/<your_username>/base-developer-image:case1 -f case1.Dockerfile . && docker push quay.io/<your_username>/base-developer-image:case1

Create a workspace with the new image. My new image is: quay.io/dkwon17/base-developer-image:case1:

<CHE_HOST>#https://github.com/che-samples/bash?image=quay.io/dkwon17/base-developer-image:case1&storageType=per-workspace

Verify that there are symlinks for config and config2:

$ ls -la /home/user/.config
total 0
drwxr-xr-x. 4 user root 50 Aug 22 20:57 .
drwxrwx---. 1 user root 62 Aug 22 20:57 ..
lrwxrwxrwx. 1 user root 28 Aug 22 20:57 config -> /home/tooling/.config/config
drwxr-xr-x. 2 user root 26 Aug 22 20:57 containers
drwxr-xr-x. 2 user root 21 Aug 22 20:57 test

$ ls -la /home/user/.config/test
total 0
drwxr-xr-x. 2 user root 21 Aug 22 20:57 .
drwxr-xr-x. 4 user root 50 Aug 22 20:57 ..
lrwxrwxrwx. 1 user root 34 Aug 22 20:57 config2 -> /home/tooling/.config/test/config2
Case 2: Testing CRW-8598

Put the following into case2.Dockerfile:

FROM <BASE_IMAGE>

RUN mkdir -p /home/tooling/.config/test

COPY config2 /home/tooling/.config/test/
COPY config /home/tooling/.config/

RUN echo ".config/test" >> /home/tooling/.copy-files

USER root

RUN chmod 777 /home/tooling/.config/test/config2

USER 1001

Build the image:

docker build -t quay.io/<your_username>/base-developer-image:case2 -f case2.Dockerfile . && docker push quay.io/<your_username>/base-developer-image:case2

Create a workspace with the new image. My new image is: quay.io/dkwon17/base-developer-image:case2:

<CHE_HOST>#https://github.com/che-samples/bash?image=quay.io/dkwon17/base-developer-image:case2&storageType=per-workspace

Verify that /home/user/.config/test/config2 exists, and is not a symlink:

$ ls -la /home/user/.config/test
total 4
drwxr-xr-x. 2 user root 21 Aug 22 21:28 .
drwxr-xr-x. 4 user root 50 Aug 22 21:27 ..
-rwxr-xr-x. 1 user root 18 Aug 22 21:28 config2

Make a change to the config2 file, and restart the workspace. Once the workpsace is restarted, the config2 file should have the changes you made before restarting the workspace.

@dkwon17
dkwon17 requested review from SDawley and svor as code owners August 6, 2025 17:54
@openshift-ci

openshift-ci Bot commented Aug 6, 2025

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: dkwon17

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Comment thread base/ubi9/Dockerfile Outdated

COPY --chown=0:0 entrypoint.sh /
COPY --chown=0:0 .stow-local-ignore /home/tooling/
COPY --chown=0:0 etc/.copy-files /home/tooling/

@svor svor Aug 8, 2025

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
COPY --chown=0:0 etc/.copy-files /home/tooling/
COPY --chown=0:0 .copy-files /home/tooling/

Or need to move .copy-files into developer-images/base/ubi9/etc folder

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Oops, thank you, fixed

…ome/user in the entrypoint

Signed-off-by: David Kwon <dakwon@redhat.com>
@dkwon17

dkwon17 commented Aug 22, 2025

Copy link
Copy Markdown
Collaborator Author

Closing in favour of: #231

@dkwon17 dkwon17 closed this Aug 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants