Skip to content

Commit aeb343d

Browse files
FIX: fixing dockerfile for lighter images
1 parent fb31545 commit aeb343d

2 files changed

Lines changed: 31 additions & 6 deletions

File tree

.github/workflows/build_latest_container.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,13 @@ jobs:
7979
steps:
8080
- name: Checkout Code
8181
uses: actions/checkout@v4
82+
- name: Free up disk space
83+
run: |
84+
sudo rm -rf /usr/share/dotnet
85+
sudo rm -rf /opt/ghc
86+
sudo rm -rf /opt/hostedtoolcache/CodeQL
87+
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
88+
df -h
8289
- name: Login to GitHub Container Registry
8390
uses: docker/login-action@v3
8491
with:
@@ -87,6 +94,8 @@ jobs:
8794
password: ${{ secrets.REGISTRY_TOKEN }}
8895
- name: Setup Docker Buildx
8996
uses: docker/setup-buildx-action@v3
97+
- name: Prune Docker system
98+
run: docker system prune -af --volumes || true
9099
- name: Build and Push Docker Image
91100
uses: docker/build-push-action@v5
92101
with:
@@ -96,3 +105,5 @@ jobs:
96105
tags: ${{ env.REGISTRY }}/${{ github.repository }}:latest
97106
cache-from: type=gha
98107
cache-to: type=gha,mode=max
108+
build-args: |
109+
BUILDKIT_INLINE_CACHE=1

Dockerfile.prod

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,27 @@
11
FROM ghcr.io/miguelcarcamov/snow:base
22

3-
# Install snow and clean up to minimize image size
4-
RUN python3 --version && \
5-
pip3 --version && \
6-
echo "Installing snow" && \
7-
pip3 install --no-cache-dir git+https://github.com/miguelcarcamov/snow.git && \
3+
# Install build tools first (smaller, can be cleaned up separately)
4+
RUN python3 -m pip install --upgrade --no-cache-dir pip wheel setuptools setuptools-scm build && \
5+
python3 -m pip cache purge
6+
7+
# Build and install snow with maximum space efficiency
8+
# Use /tmp/snow-build which we'll clean up immediately after
9+
RUN WORKDIR=/tmp/snow-build && \
10+
mkdir -p $WORKDIR && \
11+
cd $WORKDIR && \
12+
echo "Cloning snow repository..." && \
13+
git clone --depth 1 --single-branch https://github.com/miguelcarcamov/snow.git . && \
14+
echo "Building snow package..." && \
15+
python3 -m build --wheel && \
16+
echo "Installing snow..." && \
17+
pip3 install --no-cache-dir $(ls -t dist/*.whl | head -1) && \
18+
cd / && \
19+
rm -rf $WORKDIR && \
820
python3 -m pip cache purge && \
9-
rm -rf /root/.cache/pip && \
21+
rm -rf /root/.cache/pip /root/.cache/pip-tools /root/.cache/git && \
1022
rm -rf /tmp/* /var/tmp/* && \
23+
find /usr/local/lib/python3.* -type d -name __pycache__ -exec rm -rf {} + 2>/dev/null || true && \
24+
find /usr/local/lib/python3.* -type f \( -name "*.pyc" -o -name "*.pyo" \) -delete 2>/dev/null || true && \
1125
mkdir -p ~/.casa/data && \
1226
echo "Hello from snow production image"
1327
LABEL org.opencontainers.image.source="https://github.com/miguelcarcamov/snow"

0 commit comments

Comments
 (0)