Skip to content

Commit

Permalink
I hate you dockerhub
Browse files Browse the repository at this point in the history
  • Loading branch information
MU-Software committed Jan 21, 2024
1 parent 1edec1c commit 1cc986a
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 6 deletions.
11 changes: 5 additions & 6 deletions infra/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@ FROM --platform=linux/arm64 python:3.11-slim-bookworm as base

# ==============================================================================
FROM base as builder
SHELL ["bash", "-euxvc"]

RUN set -eux; \
apt-get update; \
RUN apt-get update; \
apt-get install -y --no-install-recommends curl openssh-client gcc git libpq-dev; \
curl -sSL https://install.python-poetry.org | python3.11 -;

ENV PATH="${PATH}:/root/.local/bin:"

COPY ../poetry.lock ../pyproject.toml ./

RUN set -eux; \
poetry config experimental.system-git-client true; \
RUN poetry config experimental.system-git-client true; \
poetry config virtualenvs.create false; \
poetry install --only main --no-interaction --no-ansi --no-root;

# ==============================================================================
FROM base as runtime
SHELL ["bash", "-euxvc"]

ARG GIT_HASH
ENV TZ=Asia/Seoul \
Expand All @@ -27,8 +27,7 @@ ENV TZ=Asia/Seoul \
PYTHONIOENCODING=UTF-8 \
DEPLOYMENT_GIT_HASH=$GIT_HASH

RUN set -eux; \
ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone; \
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone; \
apt-get update; \
apt-get install -y --no-install-recommends curl wget ca-certificates gnupg lsb-release;

Expand Down
10 changes: 10 additions & 0 deletions infra/hooks/build
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash
set -e

docker build \
-t $IMAGE_NAME \
-f Dockerfile \
--target runtime \
--build-arg GIT_HASH="$(git rev-parse HEAD)" \
--build-arg INVALIDATE_CACHE_DATE="$(date +%Y-%m-%d_%H:%M:%S)" \
../
13 changes: 13 additions & 0 deletions infra/hooks/pre_build
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash
set -e

HOST_ARCH=$(uname -m)

if [ x"${HOST_ARCH}" == x"aarch64" ]; then
echo "Building arm64 image natively"
exit
fi

# Register qemu-*-static for all supported processors except the
# current one, but also remove all registered binfmt_misc before
docker run --rm --privileged multiarch/qemu-user-static:register --reset

0 comments on commit 1cc986a

Please sign in to comment.