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

Fix missing adduser on the docker image ubuntu:latest. #145

Merged
merged 3 commits into from
May 11, 2024

Conversation

youpong
Copy link
Collaborator

@youpong youpong commented May 9, 2024

The docker image ubuntu:latest has been changed to 24.04 LTS.
The new image does not install the adduser command by default, which causes errors when building the docker image procfetch.
This pull request contains changes to the Dockerfile.

Related Issue(s)

This pull request fixes the issue #146.

@TanmayPatil105
Copy link
Owner

I'm getting some errors while building it in docker container

make -C src -j 
make[1]: Entering directory '/procfetch/src'
g++ -std=c++2a -Wall -Wextra --pedantic-errors    -c -o fetch.o fetch.cpp
g++ -std=c++2a -Wall -Wextra --pedantic-errors    -c -o main.o main.cpp
g++ -std=c++2a -Wall -Wextra --pedantic-errors    -c -o util.o util.cpp
Assembler messages:
Fatal error: can't create main.o: Permission denied
make[1]: *** [<builtin>: main.o] Error 1
make[1]: *** Waiting for unfinished jobs....
Assembler messages:
Fatal error: can't create util.o: Permission denied
make[1]: *** [<builtin>: util.o] Error 1
Assembler messages:
Fatal error: can't create fetch.o: Permission denied
make[1]: Leaving directory '/procfetch/src'
make[1]: *** [<builtin>: fetch.o] Error 1
make: *** [Makefile:12: src] Error 2

@youpong
Copy link
Collaborator Author

youpong commented May 10, 2024

I can't reproduce it here. My environment is as follows:

  • Docker Desktop on Mac v.4.29.0
  • macOS Sonoma 14.4.1

@TanmayPatil105
Copy link
Owner

I was able fix that error by doing:

-USER user
-WORKDIR /home/user
+WORKDIR /home/user
+USER user

I was able to run it. After running more errors:

$ sudo docker run --rm -v $PROCFETCH:/procfetch -w /procfetch procfetch make run
make -C src -j run
make[1]: Entering directory '/procfetch/src'
./procfetch

terminate called after throwing an instance of 'std::logic_error'
  what():  basic_string: construction from null is not valid
make[1]: Leaving directory '/procfetch/src'
make[1]: *** [Makefile:16: run] Aborted (core dumped)
make: *** [Makefile:12: src] Error 2

I'll try to debug this during night.
I'm using Ubuntu 24.04 and Docker version 26.1.0, build 9714adc

@youpong
Copy link
Collaborator Author

youpong commented May 10, 2024

That change in the Dockerfile works fine in my environment.

If I set a value to the USER environment variable, does it change the result?

$ USER=$(whoami) src/procfetch

@TanmayPatil105
Copy link
Owner

Yupp, It does!
Can you update this PR with both the changes?

@youpong
Copy link
Collaborator Author

youpong commented May 11, 2024

I’ve updated this PR with both changes. Check it.

Well. In the Docker container environment that we provide, it is acceptable to set the USER environment variable. Let's introduce it.

However, as this case shows, it is incorrect to assume that the environment variable USERis always available. Stopping the program in such a case is not a good behavior. We need to add a process to handle the case.

@TanmayPatil105
Copy link
Owner

However, as this case shows, it is incorrect to assume that the environment variable USERis always available. Stopping the program in such a case is not a good behavior. We need to add a process to handle the case.

Definitely, we've got a bunch of cases causing the program to halt. I'll create a separate issue for those, then we can start fixing them.

As for getting the username, we could just use the getlogin() from unistd.h. Let's think more about it?

@TanmayPatil105
Copy link
Owner

Anyways, I'm merging this PR!

@TanmayPatil105 TanmayPatil105 merged commit 9a664a8 into TanmayPatil105:main May 11, 2024
3 checks passed
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.

None yet

2 participants