Skip to content

Commit

Permalink
Make main docker image as minimal as possible to prevent big size image
Browse files Browse the repository at this point in the history
  • Loading branch information
mansuf committed Jun 6, 2024
1 parent 9857858 commit 9fa4349
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 19 deletions.
38 changes: 35 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ on:

env:
TEST_TAG: mansuf/mangadex-downloader:test
TEST_OPTIONAL_TAG: mansuf/mangadex-downloader:test-optional
LATEST_TAG: mansuf/mangadex-downloader:latest
LATEST_OPTIONAL_TAG: mansuf/mangadex-downloader:latest-optional


jobs:
docker:
Expand Down Expand Up @@ -36,13 +39,25 @@ jobs:
context: .
load: true
tags: ${{ env.TEST_TAG }}

- name: Build and export to Docker (with optional dependencies)
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile.optional
load: true
tags: ${{ env.TEST_OPTIONAL_TAG }}

- name: Test
- name: Test docker image
run: |
docker run --rm ${{ env.TEST_TAG }}
- name: Test
run: |
docker run --rm ${{ env.TEST_OPTIONAL_TAG }}
- name: Update Docker Hub description
if: startsWith(github.ref, 'refs/tags/') && github.repository == 'mansuf/mangadex-downloader'
# if: startsWith(github.ref, 'refs/tags/') && github.repository == 'mansuf/mangadex-downloader'
uses: peter-evans/dockerhub-description@v4
with:
username: ${{ secrets.DOCKER_USERNAME }}
Expand All @@ -51,7 +66,7 @@ jobs:
short-description: ${{ github.event.repository.description }}

- name: Build and push
if: startsWith(github.ref, 'refs/tags/') && github.repository == 'mansuf/mangadex-downloader'
# if: startsWith(github.ref, 'refs/tags/') && github.repository == 'mansuf/mangadex-downloader'
uses: docker/build-push-action@v5
with:
context: .
Expand All @@ -63,6 +78,23 @@ jobs:
tags: |
${{ env.LATEST_TAG }}
mansuf/mangadex-downloader:${{ github.ref_name }}
mansuf/mangadex-downloader:v2.10.3
- name: Build and push (with optional dependencies)
# if: startsWith(github.ref, 'refs/tags/') && github.repository == 'mansuf/mangadex-downloader'
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile.optional
platforms: |
linux/amd64
linux/arm64
linux/arm/v7
push: true
tags: |
${{ env.LATEST_OPTIONAL_TAG }}
mansuf/mangadex-downloader:${{ github.ref_name }}-optional
mansuf/mangadex-downloader:v2.10.3-optional
windows-build:
name: Build app & docs (Windows)
Expand Down
16 changes: 15 additions & 1 deletion .github/workflows/build_pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ on:

env:
TEST_TAG: mansuf/mangadex-downloader:test
TEST_OPTIONAL_TAG: mansuf/mangadex-downloader:test-optional
LATEST_TAG: mansuf/mangadex-downloader:latest
LATEST_OPTIONAL_TAG: mansuf/mangadex-downloader:latest-optional

jobs:
docker:
Expand All @@ -31,10 +33,22 @@ jobs:
context: .
load: true
tags: ${{ env.TEST_TAG }}

- name: Build and export to Docker (with optional dependencies)
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile.optional
load: true
tags: ${{ env.TEST_OPTIONAL_TAG }}

- name: Test docker image
run: |
docker run --rm ${{ env.TEST_TAG }}
- name: Test
run: |
docker run --rm ${{ env.TEST_TAG }}
docker run --rm ${{ env.TEST_OPTIONAL_TAG }}
windows-build:
name: Build app & docs (Windows)
Expand Down
16 changes: 1 addition & 15 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,9 @@ FROM python:3.11
COPY . /app
WORKDIR /app

# Setup rust
RUN apt update && apt install wget
ENV RUSTUP_HOME=/usr/local/rustup \
CARGO_HOME=/usr/local/cargo \
PATH=/usr/local/cargo/bin:$PATH \
RUST_VERSION=1.78.0
RUN wget https://sh.rustup.rs -O rustup.sh
RUN chmod +x ./rustup.sh
RUN ./rustup.sh -y --no-modify-path --profile minimal --default-toolchain $RUST_VERSION
RUN chmod -R a+w $RUSTUP_HOME $CARGO_HOME;
RUN rustup --version;
RUN cargo --version;
RUN rustc --version;

# Install mangadex-downloader
RUN pip install --upgrade pip
RUN pip install .[optional]
RUN pip install .

WORKDIR /downloads

Expand Down
28 changes: 28 additions & 0 deletions Dockerfile.optional
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
FROM python:3.11

COPY . /app
WORKDIR /app

# Setup rust
RUN apt update && apt install wget
ENV RUSTUP_HOME=/usr/local/rustup \
CARGO_HOME=/usr/local/cargo \
PATH=/usr/local/cargo/bin:$PATH \
RUST_VERSION=1.78.0
RUN wget https://sh.rustup.rs -O rustup.sh
RUN chmod +x ./rustup.sh
RUN ./rustup.sh -y --no-modify-path --profile minimal --default-toolchain $RUST_VERSION
RUN chmod -R a+w $RUSTUP_HOME $CARGO_HOME;
RUN rustup --version;
RUN cargo --version;
RUN rustc --version;

# Install mangadex-downloader
RUN pip install --upgrade pip
RUN pip install .[optional]

WORKDIR /downloads

ENTRYPOINT [ "mangadex-downloader" ]

CMD [ "--help" ]

0 comments on commit 9fa4349

Please sign in to comment.