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

Feature Request: Install locales through environment variables #212

Open
moqmar opened this issue Sep 15, 2020 · 7 comments
Open

Feature Request: Install locales through environment variables #212

moqmar opened this issue Sep 15, 2020 · 7 comments
Labels
bug confirmed Bug reproduced and qualified
Milestone

Comments

@moqmar
Copy link

moqmar commented Sep 15, 2020

Expected Behavior

Some stuff in PHP depends heavily on locales, so I'd expect locales to be supported by a general-purpose PHP container.

Current Behavior

I need to create a custom Dockerfile to install and install the neccessary locales:

RUN { echo en_GB.UTF-8 de_DE.UTF-8; echo C.UTF-8; } | DEBIAN_FRONTEND=teletype dpkg-reconfigure locales
ENV PHP_INI_INTL__DEFAULT_LOCALE=de_DE.UTF-8

Possible Solution

Add an environment variable LOCALES="en_GB.UTF-8 de_DE.UTF-8" that generates the locales on container start. Setting PHP_INI_INTL__DEFAULT_LOCALE can be an independent option.

Context

I want to use ProcessWire, and am trying to create as few custom Docker images as possible.

Your Environment

  • Version used: 7.4-v3-apache
  • Operating System and version: Debian 10 Buster
  • Link to your project: N/A
@moqmar moqmar changed the title Install locales through environment variables Feature Request: Install locales through environment variables Sep 15, 2020
@mistraloz mistraloz added the bug confirmed Bug reproduced and qualified label Nov 4, 2021
@mistraloz mistraloz added this to the V4 milestone Nov 4, 2021
@mbrodala
Copy link
Contributor

@daedeloth
Copy link

daedeloth commented Oct 10, 2024

+1.

I solved it for now by adding to my Dockerfile:

USER root
RUN apt-get update && apt-get install locales-all && apt-get clean

USER docker

@mbrodala
Copy link
Contributor

That supposedly installs all locales, even not necessary ones. We currently use this:

USER root

ARG LOCALES="de_DE.UTF-8"
RUN for l in ${LOCALES}; \
        do sed -i -e "s/# \(${l} .*\)/\1/" /etc/locale.gen; \
    done
RUN dpkg-reconfigure -f noninteractive locales

USER docker

Still it would be nice if this or something similar was available by default without a custom build.

@daedeloth
Copy link

daedeloth commented Oct 10, 2024

Cool, that is indeed less drastic :) Thanks, will switch to that.
*edit: actually that doesn't seem to work with thecodingmachine/php:8.0-v4-slim-apache, so switched to:

USER root
RUN apt-get update && apt-get install -y language-pack-nl && apt-get clean;
USER docker

@mbrodala
Copy link
Contributor

mbrodala commented Oct 10, 2024

Not sure what "doesnt' seem to work" mean exactly. We're using this for ages and various image versions just fine:

$ locale -a
C
C.UTF-8
POSIX
de_DE.utf8

@daedeloth
Copy link

0.116 sed: can't read /etc/locale.gen: No such file or directory

@mbrodala
Copy link
Contributor

Ah you are right, we obviously install the locales package before that:

USER root

RUN apt-get update \
    && apt-get install -y \
        ... \
        locales \
        ... \
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/*

ARG LOCALES="de_DE.UTF-8"
RUN for l in ${LOCALES}; \
        do sed -i -e "s/# \(${l} .*\)/\1/" /etc/locale.gen; \
    done
RUN dpkg-reconfigure -f noninteractive locales

USER docker

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug confirmed Bug reproduced and qualified
Projects
None yet
Development

No branches or pull requests

4 participants