Skip to content

Commit

Permalink
Add buildx caching
Browse files Browse the repository at this point in the history
  • Loading branch information
TheReverend403 committed Feb 23, 2024
1 parent 6cd1197 commit d8283be
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 26 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/build-docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ on:
push:
branches:
- "main"
- "dev"
tags:
- "*"
pull_request:
branches:
- "main"
- "dev"

env:
REGISTRY: ghcr.io
Expand Down
52 changes: 30 additions & 22 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,11 @@ ENV PATHS_NODE_MODULES=$NODE_MODULES \

FROM python-base as s6-base

RUN apt-get update && \
RUN --mount=type=cache,target=/var/cache/apt,sharing=private \
apt-get update && \
apt-get install --no-install-recommends -y \
xz-utils
xz-utils \
&& apt-get autoclean && rm -rf /var/lib/apt/lists/*

ARG S6_OVERLAY_VERSION="3.0.0.2"

Expand All @@ -53,22 +55,26 @@ RUN mkdir -p "$S6_DOWNLOAD_PATH" && \
## Python builder
FROM python-base as python-builder-base

RUN apt-get update && \
RUN --mount=type=cache,target=/var/cache/apt,sharing=private \
apt-get update && \
apt-get install --no-install-recommends -y \
curl \
build-essential \
libffi-dev \
libpq-dev
curl \
build-essential \
libffi-dev \
libpq-dev \
&& apt-get autoclean && rm -rf /var/lib/apt/lists/*

# Install poetry - respects $POETRY_VERSION & $POETRY_HOME
RUN curl -sSL https://install.python-poetry.org | python -
RUN --mount=type=cache,target=/root/.cache \
curl -sSL https://install.python-poetry.org | python -

# Copy project requirement files here to ensure they will be cached.
WORKDIR $PYSETUP_PATH
COPY poetry.lock pyproject.toml ./

# Install runtime deps - uses $POETRY_VIRTUALENVS_IN_PROJECT internally
RUN poetry install --only main
RUN --mount=type=cache,target=/root/.cache \
poetry install --no-root --only main


## JS builder
Expand All @@ -78,26 +84,28 @@ ENV NODE_MODULES="/opt/node"
WORKDIR $NODE_MODULES

COPY yarn.lock package.json ./
RUN yarn install
RUN --mount=type=cache,target=/usr/local/share/.cache/yarn \
yarn install


## Dev image
FROM python-base as development

RUN apt-get update && \
RUN --mount=type=cache,target=/var/cache/apt,sharing=private \
apt-get update && \
apt-get install --no-install-recommends -y \
libpq5 \
libmagic1

RUN apt-get clean && rm -rf /var/lib/apt/lists/*
libpq5 \
libmagic1 \
&& apt-get autoclean && rm -rf /var/lib/apt/lists/*

WORKDIR $PYSETUP_PATH

COPY --from=python-builder-base $PYSETUP_PATH $PYSETUP_PATH
COPY --from=python-builder-base $POETRY_HOME $POETRY_HOME
COPY --from=node-builder-base $NODE_MODULES/node_modules $NODE_MODULES/

RUN poetry install
RUN --mount=type=cache,target=/root/.cache \
poetry install --no-root

COPY --from=s6-base $S6_DOWNLOAD_PATH /
COPY docker/rootfs /
Expand All @@ -118,13 +126,13 @@ ENTRYPOINT ["/init"]
## Production image
FROM python-base as production

RUN apt-get update && \
RUN --mount=type=cache,target=/var/cache/apt,sharing=private \
apt-get update && \
apt-get install --no-install-recommends -y \
curl \
libpq5 \
libmagic1

RUN apt-get clean && rm -rf /var/lib/apt/lists/*
curl \
libpq5 \
libmagic1 \
&& apt-get autoclean && rm -rf /var/lib/apt/lists/*

COPY --from=python-builder-base $PYSETUP_PATH $PYSETUP_PATH
COPY --from=node-builder-base $NODE_MODULES/node_modules $NODE_MODULES/
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# pste

![GitHub](https://img.shields.io/github/license/TheReverend403/pste?style=flat-square)
![GitHub Workflow Status](https://img.shields.io/github/workflow/status/TheReverend403/pste/ci?style=flat-square)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg?style=flat-square)](https://github.com/psf/black)
![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/TheReverend403/pste/build-docker-image.yml?branch=main&style=flat-square)
[![Code style: ruff](https://img.shields.io/badge/code%20style-ruff-000000.svg?style=flat-square)](https://github.com/astral-sh/ruff)

Just a simple file hosting application inspired by the likes of pomf.se and teknik.io.

Expand All @@ -15,7 +15,7 @@ Very early alpha, 100% definitely not ready whatsoever for production use. Not e
First, install [Poetry](https://poetry.eustace.io/).

```sh
git clone https://github.com/FoxDev/pste
git clone https://github.com/TheReverend403/pste
cd pste
poetry install
yarn install # or `npm install` if you're a caveman.
Expand Down

0 comments on commit d8283be

Please sign in to comment.