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

create a dockerized service for print_label_service.py #168

Open
wants to merge 15 commits into
base: master
Choose a base branch
from

Conversation

tingox
Copy link
Contributor

@tingox tingox commented Nov 2, 2021

My attempt at fixing bitraf/bitraf-iot#19 Very much a work in progress. I have some questions:

  • is there a way to use the necessary scripts and files from the bitraf-iot repository without including the whole repo into the docker container? (For now I just copied the necessary files from that repo, but that is not a very elegant solution, IMHO)
  • how can I test this on another docker host than the default one? (say heim for example)

@tingox tingox self-assigned this Nov 2, 2021
@tingox tingox changed the title create a dockerized service for pprint_label_service.py create a dockerized service for print_label_service.py Nov 2, 2021
@tingox
Copy link
Contributor Author

tingox commented Nov 2, 2021

one question answered: the docker host is specified in the inventory file.

@mastensg
Copy link
Member

mastensg commented Nov 2, 2021

how can I test this on another docker host than the default one? (say heim for example)

hvilken som helst maskin på bitraf lan med docker og docker-compose burde kunne teste dette med (kanskje først noe mer) docker-compose up i riktig katalog

@mastensg
Copy link
Member

mastensg commented Nov 2, 2021

en feil jeg oppdaget på den måten:

$ docker-compose up
Building p2k16-label
Step 1/8 : FROM python:3.9-slim-bullseye
3.9-slim-bullseye: Pulling from library/python
7d63c13d9b9b: Pull complete

[...]

Successfully built be67bbbd9590
Successfully tagged p2k16-label:latest
WARNING: Image for service p2k16-label was built because it did not already exist. To rebuild this image you must use `docker-compose build` or `docker-compose up --build`.
Creating templates_p2k16-label_1 ... done
Attaching to templates_p2k16-label_1
p2k16-label_1  | python: can't open file '/home/app_user/print_label_service.py': [Errno 13] Permission denied
templates_p2k16-label_1 exited with code 2

@mastensg
Copy link
Member

mastensg commented Nov 2, 2021

$ docker run --rm -it label /bin/bash
app_user@c0cd2bb02940:~$ whoami
app_user
app_user@c0cd2bb02940:~$ ls -l /home/app_user/print_label_service.py 
-rwx------ 1 root root 2559 Nov  2 13:08 /home/app_user/print_label_service.py

@mastensg
Copy link
Member

mastensg commented Nov 2, 2021

er det en spesiell grunn til at du ikke vil kjøre programmet som root inni kontaineren?

@trygvis
Copy link
Contributor

trygvis commented Nov 2, 2021

I would suggest that the bitraf-iot repository takes care of producing the docker image and that this repository just installs that image. This would be similar to what we do with p2k16, postgresql and the other images.

The p2k16 repository has its own docker-compose.yml for local testing of the image. I see now that that docker-compose actually doesn't include a p2k16 service, but it could :).

@tingox
Copy link
Contributor Author

tingox commented Nov 2, 2021

er det en spesiell grunn til at du ikke vil kjøre programmet som root inni kontaineren?

ikke noe annet enn at det er "best practice" å kjøre som en annen bruker enn root.

@mastensg
Copy link
Member

mastensg commented Nov 2, 2021

ok. jeg ser det er gjort sånn i p2k16 sin Dockerfile også, men riktig :)

https://github.com/bitraf/p2k16/blob/master/docker/Dockerfile

@mastensg
Copy link
Member

mastensg commented Nov 2, 2021

(altså COPY --chown=p2k16 ...)

@trygvis
Copy link
Contributor

trygvis commented Nov 2, 2021

Det riktige i dette tilfellet hadde vel bare vært chmod a+r. I p2k16 så kjøres pip install som p2k16 som peller på filene i imaget.

P2k16 skulle ideelt sett delt opp bygging og kjøring i to images, men jeg har ikke orket enda.

@tingox
Copy link
Contributor Author

tingox commented Nov 5, 2021

ok, this is now working, and ready for review. Fixes bitraf/bitraf-iot#19.

@tingox
Copy link
Contributor Author

tingox commented Aug 29, 2023

See also #125

Copy link
Contributor

@trygvis trygvis left a comment

Choose a reason for hiding this comment

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

Looks good to me after a quick read!

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.

3 participants