내용으로 건너뛰기

locale.Error: unsupported locale setting

0

I'm trying to pull up my app developed in Django directly from the Github repository with the App Runner service. I have the following configuration in the apprunner.yaml file

version: 1.0
runtime: python311
build:
  commands:
    pre-build:
      - export LC_ALL=es_ES.UTF-8
      - export LC_TIME=es_ES.UTF-8
      - export LANG=es_ES.UTF-8
    build:
      - pip3 install pipenv
      - pipenv install
run:
  runtime-version: 3.11.9
  pre-run:
    - pip3 install pipenv
    - pipenv install
  command: pipenv run gunicorn conf.wsgi --workers 2 --log-file -
  network:
    port: 8000

Successfully built the source code from the app but the app logs I got the following error:

return _setlocale(category, locale)
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
locale.Error: unsupported locale setting

I thought that adding these export lines in the yaml file would solve the error but it doesn't work. Will it be possible to install the "locales" or "locales-all" Ubuntu packages or similar to solve the error? I need to have the es_ES.UTF-8 language available

thanks for your comments :)

질문됨 2년 전900회 조회
2개 답변
5
수락된 답변

Hello,

Instead of using apprunner.yaml, you can:

Customize a Docker Container:

  • Build a Docker container locally with your required locale settings.
  • Push the container to Amazon ECR.
  • Use this custom container in AWS App Runner.

Install Locale Packages in apprunner.yaml:

  • If you prefer using apprunner.yaml, add the necessary locale package installation:
version: 1.0
runtime: python311
build:
  commands:
    pre-build:
      - yum install -y glibc-all-langpacks
      - export LC_ALL=es_ES.UTF-8
      - export LC_TIME=es_ES.UTF-8
      - export LANG=es_ES.UTF-8
    build:
      - pip3 install pipenv
      - pipenv install
run:
  runtime-version: 3.11.9
  pre-run:
    - pip3 install pipenv
    - pipenv install
  command: pipenv run gunicorn conf.wsgi --workers 2 --log-file -
  network:
    port: 8000

https://docs.aws.amazon.com/apprunner/latest/dg/service-source-code.html#service-source-code.managed-platforms

https://docs.aws.amazon.com/linux/al2023/ug/image-comparison.html

전문가
답변함 2년 전
전문가
검토됨 2년 전
전문가
검토됨 2년 전
전문가
검토됨 2년 전
  • I tried your solution and it worked, thanks. Also I had to add the following line in the pre-build to set the language: localedef -i en_ES -f UTF-8 en_ES.UTF-8

1

Hello.

Instead of building with apprunner.yaml, I think you can customize the container as you like by building the container using Dockerfile etc. on your local PC and pulling it from ECR to AppRunner.

When using apprunner.yaml, the container OS seems to be based on Amazon Linux, so you may be able to install it by adding "yum glibc-all-langpacks" to the build section.
https://docs.aws.amazon.com/apprunner/latest/dg/service-source-code.html#service-source-code.managed-platforms

This image is based on the Amazon Linux Docker image and contains a language runtime package as well as some tools and popular dependency packages.

If Amazon Linux 2023 is used, I think "glibc-all-langpacks" can be installed.
https://docs.aws.amazon.com/linux/al2023/ug/image-comparison.html

전문가
답변함 2년 전
전문가
검토됨 2년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

관련 콘텐츠