Skip to content

Commit

Permalink
Test build demo gallery
Browse files Browse the repository at this point in the history
  • Loading branch information
rigon committed Dec 15, 2024
1 parent 7238ce1 commit 38ef2fb
Showing 1 changed file with 27 additions and 44 deletions.
71 changes: 27 additions & 44 deletions Dockerfile.demo
Original file line number Diff line number Diff line change
@@ -1,50 +1,33 @@
FROM python:alpine AS pixabay

RUN pip install pixabay

RUN --mount=type=secret,id=token \
python <<EOF
token="NO TOKEN"
with open('/run/secrets/token', 'r') as file:
token = file.read()

print(token)

with open('/test.txt', 'w') as file:
file.write("Hello, World!\n")
file.write(token)

import pixabay.core, os

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"]

with open('/run/secrets/pixabay', 'r') as file:
apiKey = file.read()

px = pixabay.core(apiKey)
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

# with open('/run/secrets/token', 'r') as file:
# token = file.read()
# print(token)
# file.write(token)

# RUN pip install pixabay

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

# 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
FROM rigon/photo-gallery:dev
COPY --from=pixabay /photos /photos
RUN touch /photos/Favorites.PG-ALBUM

0 comments on commit 38ef2fb

Please sign in to comment.