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

Try using alpine-based docker image (musl locale issues) #125

Closed
jantman opened this issue Oct 18, 2017 · 6 comments
Closed

Try using alpine-based docker image (musl locale issues) #125

jantman opened this issue Oct 18, 2017 · 6 comments

Comments

@jantman
Copy link
Owner

jantman commented Oct 18, 2017

The Docker image for this is based on the non-alpine (debian) variant of the official Python image, which is 535 MB as opposed to 89 MB for alpine.

@jantman
Copy link
Owner Author

jantman commented Oct 22, 2017

Tried work on this in noci-issues/125 branch, as of 152f1a6

Doesn't work. Alpine Linux is based on the musl C library, which doesn't have locale support. As a result, our many calls to locale.currency() fail with:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/local/lib/python3.6/locale.py", line 262, in currency
    raise ValueError("Currency formatting is not possible using "
ValueError: Currency formatting is not possible using the 'C' locale.

This issue needs to either wait for a usable musl locale support, or some non-Alpine (non-musl) tiny base image.

@jantman jantman changed the title Try using alpine-based docker image Try using alpine-based docker image (musl locale issues) Oct 22, 2017
@jantman jantman added the ready label Oct 28, 2017
@jantman
Copy link
Owner Author

jantman commented Oct 28, 2017

Ok, I've found a solution to this problem. The babel package is specifically designed to aid i18n and l10n in Python web applications, and has a format_currency function that doesn't rely on locale support, and works correctly in the Alpine-based Docker images. The function takes three arguments; the value to format, the currency specifier (i.e. 'USD') and the locale (i.e. 'en_US'). This does mean that we should probably make the currency specifier a configuration value, and should probably make the locale a configuration value as well, that we attempt to get from the environment/system if possible (or at least allow it to be overridden via env vars).

The locale issues with the Alpine image brought up some issues around Javascript, but we'll handle those in #140.

@jantman
Copy link
Owner Author

jantman commented Oct 28, 2017

When I try this, bump to the 3.6.3-alpine3.6 image, or a newer one if available. Also, the locale test needs to be removed.

@jantman
Copy link
Owner Author

jantman commented Nov 3, 2017

I don't know if this was happening before or not, but now I can't get phantomJS to run in the Alpine image. It seems like I'm hitting ariya/phantomjs#14186 where PhantomJS just doesn't work on Alpine/musl, and there doesn't seem to be a clear workaround at this time (though it seems like it did with earlier phantom and/or musl versions?)

@jantman
Copy link
Owner Author

jantman commented Nov 3, 2017

Ok, I managed to find https://github.com/fgrehm/docker-phantomjs2 which provides a working phantomjs on Alpine in Docker, albeit phantomjs 2.0.0 instead of 2.1.1

@jantman
Copy link
Owner Author

jantman commented Nov 4, 2017

Ok, using the last commit I have acceptance tests passing against an Alpine-based Docker container, and I have phantomjs 2.0.0 running in the container itself.

jantman added a commit that referenced this issue Nov 4, 2017
@jantman jantman added in progress and removed ready labels Nov 4, 2017
@jantman jantman closed this as completed in 775a78c Nov 4, 2017
jantman added a commit that referenced this issue Nov 4, 2017
@jantman jantman reopened this Nov 4, 2017
@jantman jantman closed this as completed Nov 12, 2017
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

No branches or pull requests

1 participant