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

EDEV-6 - Remove dev and move commands into root web #1374

Closed
wants to merge 36 commits into from

Conversation

ahosgood
Copy link
Member

@ahosgood ahosgood commented Oct 13, 2023

https://national-archives.atlassian.net/browse/EDEV-6

  • Removed the dev Docker container
  • Using a new variant of the tna-docker-django image; tna-docker-django-root which has the user set to root
  • Can now change Docker image and tag for development without affecting builds on GitHub CI which continue to use the non-root version
  • Commands can now be run in the web container with fab dev followed by things like dev-css - hopefully really similar to how they are now
  • Running as root during development means we can write changes back to the file system such as the format command without the changes being owned by the container user
  • The admin user admin is created on boot with the password admin which should speed up development
  • Add configuration for isort, black and flake8

@ahosgood ahosgood changed the title Remove dev and move commands into root web EDEV-6 - Remove dev and move commands into root web Oct 17, 2023
@ahosgood ahosgood requested a review from jamesbiggs October 31, 2023 15:43
Copy link
Collaborator

@jamesbiggs jamesbiggs left a comment

Choose a reason for hiding this comment

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

Hi AJ,
I'm still getting the permissions error when running format - is there a way that you can run sudo chown -R user:user . after the format commands are run? That'd give the permissions back to the user we're currently on (not sure how to directly get the user though, but I've been running sudo chown -R james:james .) Only issue is this would need to be run outside the container, I think.

I'm also not getting images load after running fab pull-staging-media, I see them in the ds-wagtail-media volume but just getting blank images on the FE.

It looks like the management commands are getting run inside the container only as well, so if I do, for example, manage startapp appname, it creates the new app folder inside the container's folders but doesn't get replicated on my local machine so I can't see/edit the files

@jamesbiggs
Copy link
Collaborator

WARN[0000] The "UID" variable is not set. Defaulting to a blank string. 
WARN[0000] The "GID" variable is not set. Defaulting to a blank string. 
time="2023-11-07T15:15:19Z" level=warning msg="The \"UID\" variable is not set. Defaulting to a blank string."
time="2023-11-07T15:15:19Z" level=warning msg="The \"GID\" variable is not set. Defaulting to a blank string."

I think the user: "${UID}:${GID}" isn't getting set properly on my machine

@ahosgood ahosgood added the chore Improvements or additions to the codebase without a JIRA ticket label Nov 17, 2023
@jamesbiggs
Copy link
Collaborator

Just tested this again in WSL and on normal Windows and I'm getting this error on both

failed to solve: ghcr.io/nationalarchives/tna-python-django-root:rooted-images: ghcr.io/nationalarchives/tna-python-django-root:rooted-images: not found
#5 [web internal] load metadata for ghcr.io/nationalarchives/tna-python-django-root:rooted-images
#5 ERROR: ghcr.io/nationalarchives/tna-python-django-root:rooted-images: not found

#7 [cli internal] load metadata for docker.io/pjcdawkins/platformsh-cli:latest
#7 ERROR: failed to authorize: Unavailable: error reading from server: EOF

@jamesbiggs
Copy link
Collaborator

On Linux (WSL): I've just tried this again to see what outcome we get, the Django commands are still getting run as root rather than my user, so I don't have the correct permissions to edit them.

e.g. makemigrations creates a migration, I can see it, but if I try to make any edits to it - I get the "Failed to save" error because I don't have the right permissions... I can combat this by exiting the container and running sudo chown -R james:james . which works, I wonder if there's any way to run these after any manage X or makemigrations commands are run? Maybe we could put it in the bash files?

On Windows: Everything is working as expected! I'm happy to swap back to Windows if it means this works, but I think Ian might want to stay on Linux.

@jamesbiggs jamesbiggs self-requested a review June 6, 2024 10:30
Copy link
Collaborator

@jamesbiggs jamesbiggs left a comment

Choose a reason for hiding this comment

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

After I have set my WSL user to root, I can now use this perfectly 👌 Same for Windows, that works without any changes needed. Happy to approve this now, but we will need to sort out the other Windows (WSL) dev laptops as well 😃

@jamesbiggs
Copy link
Collaborator

@ahosgood before merging could you run the formatters here please? I'm getting some test errors when using this

@jamesbiggs
Copy link
Collaborator

Develop detail_url
image

This PR's detail_url
image

Also looks like cookies aren't working according to these tests now?
image

@ahosgood ahosgood mentioned this pull request Nov 5, 2024
10 tasks
@ahosgood
Copy link
Member Author

Replaced with #1743

@ahosgood ahosgood closed this Nov 25, 2024
@ahosgood ahosgood deleted the chore/root-docker branch January 6, 2025 17:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore Improvements or additions to the codebase without a JIRA ticket
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants