Skip to content

Commit

Permalink
build: Use tmpfs for cargo cache
Browse files Browse the repository at this point in the history
That seems to workaround rust-lang/cargo#8719.
  • Loading branch information
nijel committed Nov 23, 2021
1 parent b52b843 commit 2efb1b2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
4 changes: 4 additions & 0 deletions .github/bin/get-buildx-args
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ if [ "$1" != "publish" ] ; then
echo --cache-to "type=local,dest=/tmp/.buildx-cache/$MATRIX_ARCHITECTURE"
fi

# Workaround for https://github.com/rust-lang/cargo/issues/8719,
# see Dockerfile as well
echo --allow security.insecure

if [ "$1" = "load" ] ; then
# Ommit list of platforms loading, see https://github.com/docker/buildx/issues/59
echo --output=type=docker
Expand Down
16 changes: 10 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ FROM debian:bullseye-20211115-slim
ENV VERSION 4.9.1
ARG TARGETARCH

# Workaround for https://github.com/rust-lang/cargo/issues/8719,
# see below in the Dockerfile and .github/bin/get-buildx-args as well
# syntax = docker/dockerfile:experimental

LABEL name="Weblate"
LABEL version=$VERSION
LABEL maintainer="Michal Čihař <[email protected]>"
Expand Down Expand Up @@ -46,6 +50,10 @@ ENV PYTHONUNBUFFERED=1

COPY requirements.txt patches /usr/src/weblate/

# Workaround for https://github.com/rust-lang/cargo/issues/8719,
# see top Dockerfile and .github/bin/get-buildx-args as well
RUN mkdir -p /root/.cargo && chmod 777 /root/.cargo && mount -t tmpfs none /root/.cargo

# Install dependencies
# hadolint ignore=DL3008,DL3013,SC2046
RUN \
Expand Down Expand Up @@ -110,11 +118,6 @@ RUN \
fi \
&& curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y \
&& source $HOME/.cargo/env \
# Handle an extremely specific issue when building the cryptography package for \
# 32-bit architectures within QEMU running on a 64-bit host (issue #30). \
&& if [ "${BUILDX_QEMU_ENV}" = "true" -a "$(getconf LONG_BIT)" = "32" ] ; then \
sed -i s/^cryptography==/cryptography==3.3.2/ /usr/src/weblate/requirements.txt ; \
fi \
&& python3 -m pip install --no-cache-dir --upgrade $(grep -E '^(pip|wheel|setuptools)==' /usr/src/weblate/requirements.txt) \
&& python3 -m pip install --no-cache-dir --no-binary :all: $(grep ^cffi== /usr/src/weblate/requirements.txt) \
&& case "$VERSION" in \
Expand Down Expand Up @@ -159,7 +162,8 @@ RUN \
&& apt-get -y autoremove \
&& apt-get clean \
&& rustup self uninstall -y \
&& rm -rf /root/.cache /tmp/* /var/lib/apt/lists/*
&& rm -rf /root/.cache /tmp/* /var/lib/apt/lists/* \
&& umount /root/.cargo && rmdir /root/.cargo

# Apply hotfixes on Weblate
RUN find /usr/src/weblate -name '*.patch' -print0 | sort -z | \
Expand Down

0 comments on commit 2efb1b2

Please sign in to comment.