Skip to content

Commit 08671b6

Browse files
committed
Dockerfile: Use Tailwind CLI for faster build
1 parent dc921ca commit 08671b6

File tree

1 file changed

+21
-20
lines changed

1 file changed

+21
-20
lines changed

Dockerfile

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,11 @@
11
ARG RELEASE="0.0.0-unknown"
22

33

4-
FROM node:lts-alpine AS tailwind
5-
6-
# Compile Tailwind CSS
7-
RUN mkdir -p /opt/build
8-
COPY tailwind.config.js /opt/build/
9-
COPY dashboard/ /opt/build/dashboard
10-
WORKDIR /opt/build
11-
RUN npm install -D tailwindcss && \
12-
npx tailwindcss -i ./dashboard/static/css/base.css \
13-
-o ./dashboard/static/css/main.css --minify
14-
15-
16-
FROM python:3.12 AS dependencies
4+
FROM --platform=$BUILDPLATFORM python:3.11 AS dependencies
5+
ARG TARGETARCH
176

187
# Install build-essential for building Python packages
19-
RUN apt-get update && apt-get install -y build-essential
8+
RUN apt-get update && apt-get install -y build-essential curl
209

2110
# Install Poetry
2211
RUN pip install poetry==1.8.2
@@ -25,21 +14,33 @@ ENV POETRY_NO_INTERACTION=1 \
2514
POETRY_VIRTUALENVS_CREATE=1 \
2615
POETRY_CACHE_DIR=/tmp/poetry_cache
2716

28-
# Install dependencies
17+
# Copy files
2918
WORKDIR /app
30-
COPY pyproject.toml poetry.lock ./
31-
RUN --mount=type=cache,target=$POETRY_CACHE_DIR poetry install --without dev
32-
RUN --mount=type=cache,target=$POETRY_CACHE_DIR poetry add setuptools
19+
COPY pyproject.toml poetry.lock tailwind.config.js dashboard/static/css/base.css ./
3320

21+
# Install dependencies
22+
RUN --mount=type=cache,target=$POETRY_CACHE_DIR poetry install --without dev
3423

35-
FROM python:3.12-slim AS main
24+
# Compile Tailwind CSS
25+
RUN echo "Downloading Tailwind CLI for ${TARGETARCH}" && \
26+
if [ "${TARGETARCH}" = "arm64" ]; then \
27+
curl -sL https://github.com/tailwindlabs/tailwindcss/releases/latest/download/tailwindcss-linux-arm64 -o ./tailwindcss; \
28+
else \
29+
echo "Downloading amd64 version of Tailwind CSS"; \
30+
curl -sL https://github.com/tailwindlabs/tailwindcss/releases/latest/download/tailwindcss-linux-amd64 -o ./tailwindcss; \
31+
fi && \
32+
chmod +x ./tailwindcss && \
33+
./tailwindcss -i ./base.css -o ./main.css --minify
34+
35+
36+
FROM python:3.11-slim AS main
3637
ARG RELEASE
3738
LABEL maintainer="Jared Dantis <[email protected]>"
3839

3940
# Copy bot files
4041
COPY . /opt/app
4142
COPY --from=dependencies /app/.venv /opt/venv
42-
COPY --from=tailwind /opt/build/dashboard/static/css/main.css /opt/app/dashboard/static/css/main.css
43+
COPY --from=dependencies /app/main.css /opt/app/dashboard/static/css/main.css
4344
WORKDIR /opt/app
4445

4546
# Set release

0 commit comments

Comments
 (0)