Skip to content

fix(docker): create home directory for codegpt user in container#260

Merged
appleboy merged 1 commit intomainfrom
docker
Mar 7, 2026
Merged

fix(docker): create home directory for codegpt user in container#260
appleboy merged 1 commit intomainfrom
docker

Conversation

@appleboy
Copy link
Owner

@appleboy appleboy commented Mar 7, 2026

  • Replace file.IsDir check with direct os.MkdirAll to avoid fatal error when config directory path does not exist
  • Remove -H flag from adduser so the home directory is created for the codegpt user in Docker

fix #256

- Replace file.IsDir check with direct os.MkdirAll to avoid fatal error when config directory path does not exist
- Remove -H flag from adduser so the home directory is created for the codegpt user in Docker

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings March 7, 2026 14:37
@appleboy appleboy merged commit ac8886b into main Mar 7, 2026
22 of 27 checks passed
@appleboy appleboy deleted the docker branch March 7, 2026 14:37
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a Docker container issue (GitHub issue #256) where the codegpt user's home directory was not created in the container, causing fatal errors when the application tried to access its config directory at /home/codegpt/.config/codegpt.

Changes:

  • Removed the -H flag from adduser in the Dockerfile so the home directory is created for the codegpt user
  • Simplified config folder creation in cmd/cmd.go by replacing the file.IsDir check + conditional os.MkdirAll with a direct os.MkdirAll call, which handles non-existent parent paths gracefully

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
docker/Dockerfile Removed -H flag from adduser to ensure /home/codegpt is created
cmd/cmd.go Replaced file.IsDir check with direct os.MkdirAll for config folder creation to avoid fatal error when path doesn't exist

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +96 to +97
if err := os.MkdirAll(configFolder, os.ModePerm); err != nil {
log.Fatalf("failed to create config folder %s: %v", configFolder, err)
Copy link

Copilot AI Mar 7, 2026

Choose a reason for hiding this comment

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

The same file.IsDir pattern that caused the original bug (issue #256) still exists in the prompt folder handling below (lines 139-142, 162-165, and 177-180). For example, in the default case at line 177, if $HOME/.config/codegpt/prompt doesn't exist, file.IsDir will return an error from os.Stat, and the code will log.Fatalf before os.MkdirAll has a chance to create it. Consider applying the same os.MkdirAll fix to all three prompt folder cases as well.

Copilot uses AI. Check for mistakes.
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.

Deployment using .gitlab‑ci.yml fails to access the config folder

2 participants