Skip to content

Commit

Permalink
Merge branch 'master' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
rigon committed Dec 10, 2024
2 parents e1e6a83 + c12c85d commit df62eda
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 8 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,5 @@ jobs:
platforms: linux/amd64,linux/arm64,linux/arm/v6
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
secrets: |
pixabay=${{ secrets.PIXABAY_API_KEY }}
38 changes: 30 additions & 8 deletions Dockerfile.demo
Original file line number Diff line number Diff line change
@@ -1,9 +1,31 @@
FROM rigon/photo-gallery:dev
FROM python:alpine

RUN pip install pixabay

RUN --mount=type=secret,id=pixabay \
PIXABAY_API_KEY=$(cat /run/secrets/pixabay) && \
python <<EOF
import pixabay.core, os

RUN touch /photos/Favorites.PG-ALBUM; \
set -- Nature Film Animals Travel People "Machu Picchu" "The Grand Canyon" "Great Barrier Reef" Maldives Paris Iceland \
Wallpapers/Moutains Wallpapers/Rivers Wallpapers/Lanscapes Wallpapers/Abstract Wallpapers/Gradients Wallpapers/Patterns; \
for term in "$@"; do \
mkdir -p "/photos/$term"; \
for i in $(seq 1 50); do wget -O "/photos/$term/$i.jpg" "https://source.unsplash.com/random?$(echo $term | sed 's/ /%20/g')"; done; \
done
terms=["Nature", "Architecture", "Animals", "Travel", "People", "Autumn", "The Grand Canyon", "Great Barrier Reef", "Maldives", "Paris", "Iceland",
"Wallpapers/Moutains", "Wallpapers/Rivers", "Wallpapers/Lanscapes", "Wallpapers/Abstract", "Wallpapers/Gradients", "Wallpapers/Patterns"]

px = pixabay.core(os.environ["PIXABAY_API_KEY"])
for term in terms:
os.makedirs("/photos/"+term)
search = px.query(
query = term.replace("/", " "),
perPage = 50,
minWidth = 500,
minHeight = 500,
safeSearch = True,
)
for i in range(50):
filename = "/photos/%s/%d.jpg" % (term, i+1)
print(filename)
search[i].download(filename, "largeImage")
EOF

FROM rigon/photo-gallery:dev
COPY --from=pixabay /photos /photos
RUN touch /photos/Favorites.PG-ALBUM

0 comments on commit df62eda

Please sign in to comment.