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

Add Dockerfile for Raspberry Pi #21

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM python:3
WORKDIR /python

COPY . /python
RUN pip3 install -r requirements.txt

EXPOSE 8013
ENTRYPOINT [ "python3", "brother_ql_web.py" ]
8 changes: 8 additions & 0 deletions Dockerfile.armhf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM arm32v7/python:3
WORKDIR /python

COPY . /python
RUN pip3 install -r requirements.txt

EXPOSE 8013
ENTRYPOINT [ "python3", "brother_ql_web.py" ]
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,17 @@ All in all, the web server offers:
* an API at `/api/print/text?text=Your_Text&font_size=100&font_family=Minion%20Pro%20(%20Semibold%20)`
to print a label containing 'Your Text' with the specified font properties.

### Development

'Cross-compile' with *Docker for Mac*:

docker pull --platform arm arm32v7/python:3
docker build --no-cache -t brother_ql_web:armhf -f Dockerfile.armhf .

Copy over to the Pi with:

docker save brother_ql_web:armhf | gzip | ssh [email protected] 'gunzip | docker load'

### License

This software is published under the terms of the GPLv3, see the LICENSE file in the repository.
Expand All @@ -87,3 +98,4 @@ Parts of this package are redistributed software products from 3rd parties. They
* [Bootstrap](https://github.com/twbs/bootstrap), MIT License
* [Glyphicons](https://getbootstrap.com/docs/3.3/components/#glyphicons), MIT License (as part of Bootstrap 3.3)
* [jQuery](https://github.com/jquery/jquery), MIT License
* [Bitstream Vera Fonts](https://www.gnome.org/fonts/)
15 changes: 14 additions & 1 deletion brother_ql_web.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,10 @@ def create_label_im(text, **kwargs):
def get_preview_image():
context = get_label_context(request)
im = create_label_im(**context)
label_type = context['kind']
if label_type in (ROUND_DIE_CUT_LABEL,):
draw = ImageDraw.Draw(im)
draw.ellipse([(0, 0), (im.size[0], im.size[1])])
return_format = request.query.get('return_format', 'png')
if return_format == 'base64':
import base64
Expand Down Expand Up @@ -218,6 +222,7 @@ def main():
parser.add_argument('--port', default=False)
parser.add_argument('--loglevel', type=lambda x: getattr(logging, x.upper()), default=False)
parser.add_argument('--font-folder', default=False, help='folder for additional .ttf/.otf fonts')
parser.add_argument('--system-fonts', action='store_true', help='Include fonts installed in OS.')
parser.add_argument('--default-label-size', default=False, help='Label size inserted in your printer. Defaults to 62.')
parser.add_argument('--default-orientation', default=False, choices=('standard', 'rotated'), help='Label orientation, defaults to "standard". To turn your text by 90°, state "rotated".')
parser.add_argument('--model', default=False, choices=models, help='The model of your printer (default: QL-500)')
Expand Down Expand Up @@ -256,6 +261,10 @@ def main():
else:
ADDITIONAL_FONT_FOLDER = CONFIG['SERVER']['ADDITIONAL_FONT_FOLDER']

if args.system_fonts:
SYSTEM_FONTS = True
else:
SYSTEM_FONTS = CONFIG['SERVER']['INCLUDE_SYSTEM_FONTS']

logging.basicConfig(level=LOGLEVEL)

Expand All @@ -268,7 +277,11 @@ def main():
if CONFIG['LABEL']['DEFAULT_SIZE'] not in label_sizes:
parser.error("Invalid --default-label-size. Please choose on of the following:\n:" + " ".join(label_sizes))

FONTS = get_fonts()
if SYSTEM_FONTS:
FONTS = get_fonts()
else:
FONTS = get_fonts('./fonts')

if ADDITIONAL_FONT_FOLDER:
FONTS.update(get_fonts(ADDITIONAL_FONT_FOLDER))

Expand Down
3 changes: 2 additions & 1 deletion config.example.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"PORT": 8013,
"HOST": "",
"LOGLEVEL": "WARNING",
"ADDITIONAL_FONT_FOLDER": false
"ADDITIONAL_FONT_FOLDER": false,
"INCLUDE_SYSTEM_FONTS": false
},
"PRINTER": {
"MODEL": "QL-500",
Expand Down
Binary file added fonts/Vera.ttf
Binary file not shown.
Binary file added fonts/VeraBI.ttf
Binary file not shown.
Binary file added fonts/VeraBd.ttf
Binary file not shown.
Binary file added fonts/VeraIt.ttf
Binary file not shown.
Binary file added fonts/VeraMoBI.ttf
Binary file not shown.
Binary file added fonts/VeraMoBd.ttf
Binary file not shown.
Binary file added fonts/VeraMoIt.ttf
Binary file not shown.
Binary file added fonts/VeraMono.ttf
Binary file not shown.
Binary file added fonts/VeraSe.ttf
Binary file not shown.
Binary file added fonts/VeraSeBd.ttf
Binary file not shown.