Skip to content

Commit 104ff5f

Browse files
authored
fix(docker): Set UTF-8 locale environment variables to fix Python UnicodeEncodeError (#10378)
Without LANG and LC_ALL set to C.UTF-8, embedded Python in Docker containers fails with "UnicodeEncodeError: 'ascii' codec can't encode character" when outputting non-ASCII characters. This adds the locale environment variables to all Dockerfiles that run Python code at runtime.
1 parent bac3cd0 commit 104ff5f

7 files changed

Lines changed: 15 additions & 0 deletions

packages/cubejs-docker/dev.Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,8 @@ COPY packages/cubejs-docker/bin/cubejs-dev /usr/local/bin/cubejs
184184
# By default Node dont search in parent directory from /cube/conf, @todo Reaserch a little bit more
185185
ENV NODE_PATH /cube/conf/node_modules:/cube/node_modules
186186
ENV PYTHONUNBUFFERED=1
187+
ENV LANG=C.UTF-8
188+
ENV LC_ALL=C.UTF-8
187189
RUN ln -s /cubejs/packages/cubejs-docker /cube
188190
RUN ln -s /cubejs/rust/cubestore/bin/cubestore-dev /usr/local/bin/cubestore-dev
189191

packages/cubejs-docker/latest-debian-jdk.Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ COPY --chown=cube:cube --from=builder /cube .
4949
# By default Node dont search in parent directory from /cube/conf, @todo Reaserch a little bit more
5050
ENV NODE_PATH /cube/conf/node_modules:/cube/node_modules
5151
ENV PYTHONUNBUFFERED=1
52+
ENV LANG=C.UTF-8
53+
ENV LC_ALL=C.UTF-8
5254
RUN ln -s /cube/node_modules/.bin/cubejs /usr/local/bin/cubejs
5355
RUN ln -s /cube/node_modules/.bin/cubestore-dev /usr/local/bin/cubestore-dev
5456

packages/cubejs-docker/latest.Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ RUN DEBIAN_FRONTEND=noninteractive \
3636
RUN yarn policies set-version v1.22.22
3737

3838
ENV NODE_ENV=production
39+
ENV LANG=C.UTF-8
40+
ENV LC_ALL=C.UTF-8
3941

4042
WORKDIR /cube
4143

packages/cubejs-docker/local.Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ RUN yarn install --prod && yarn cache clean && yarn link:dev
4141
# By default Node dont search in parent directory from /cube/conf, @todo Reaserch a little bit more
4242
ENV NODE_PATH /cube/conf/node_modules:/cube/node_modules
4343
ENV PYTHONUNBUFFERED=1
44+
ENV LANG=C.UTF-8
45+
ENV LC_ALL=C.UTF-8
4446
RUN ln -s /cube/node_modules/.bin/cubejs /usr/local/bin/cubejs
4547
RUN ln -s /cube/node_modules/.bin/cubestore-dev /usr/local/bin/cubestore-dev
4648

packages/cubejs-docker/testing-drivers.Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,9 @@ COPY packages/cubejs-docker/bin/cubejs-dev /usr/local/bin/cubejs
179179

180180
# By default Node dont search in parent directory from /cube/conf, @todo Reaserch a little bit more
181181
ENV NODE_PATH /cube/conf/node_modules:/cube/node_modules
182+
ENV PYTHONUNBUFFERED=1
183+
ENV LANG=C.UTF-8
184+
ENV LC_ALL=C.UTF-8
182185
RUN ln -s /cubejs/packages/cubejs-docker /cube
183186
RUN ln -s /cubejs/rust/cubestore/bin/cubestore-dev /usr/local/bin/cubestore-dev
184187

rust/cubestore/cross/aarch64-unknown-linux-gnu-python.Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,5 @@ RUN wget https://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VER
3030
ENV PYO3_CROSS_PYTHON_VERSION=${PYTHON_RELEASE} \
3131
PYO3_CROSS_INCLUDE_DIR=/usr/aarch64-linux-gnu/include \
3232
PYO3_CROSS_LIB_DIR=/usr/aarch64-linux-gnu/lib
33+
ENV LANG=C.UTF-8
34+
ENV LC_ALL=C.UTF-8

rust/cubestore/cross/x86_64-unknown-linux-gnu-python.Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,5 @@ RUN cd tmp && wget https://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${
1818
&& cd .. && rm -rf Python-${PYTHON_VERSION};
1919

2020
ENV PYO3_PYTHON=python${PYTHON_RELEASE}
21+
ENV LANG=C.UTF-8
22+
ENV LC_ALL=C.UTF-8

0 commit comments

Comments
 (0)