Compare commits

...

14 Commits

Author SHA1 Message Date
Lee
8f91eba0f7 Merge pull request 'Add auto downloading of files' (#4) from development into master
All checks were successful
Publish Docker Image / docker (push) Successful in 1m39s
Reviewed-on: #4
2023-07-12 13:45:19 +00:00
d6122ff404 bump version
All checks were successful
Publish Docker Image / docker (push) Successful in 1m40s
2023-07-12 14:42:14 +01:00
692227f420 fix wget command
All checks were successful
Publish Docker Image / docker (push) Successful in 1m40s
2023-07-12 14:38:42 +01:00
1379ee5de5 make wget less verbose
All checks were successful
Publish Docker Image / docker (push) Successful in 1m38s
2023-07-12 14:35:49 +01:00
6cf6227a10 fix the fixing of the fix kind
All checks were successful
Publish Docker Image / docker (push) Successful in 1m40s
2023-07-12 14:26:54 +01:00
19fde36765 fix installing wget
Some checks failed
Publish Docker Image / docker (push) Failing after 28s
2023-07-12 14:25:57 +01:00
e14f155945 fix missing wget package
Some checks failed
Publish Docker Image / docker (push) Failing after 28s
2023-07-12 14:24:42 +01:00
4d8ea7f95b install wget
Some checks failed
Publish Docker Image / docker (push) Failing after 25s
2023-07-12 14:23:50 +01:00
0dd750a115 fix if statement
All checks were successful
Publish Docker Image / docker (push) Successful in 1m22s
2023-07-12 14:20:53 +01:00
98b7ad12cc enable public directory by default 2023-07-12 14:18:43 +01:00
c28f50f49e fix check
All checks were successful
Publish Docker Image / docker (push) Successful in 2m10s
2023-07-12 14:17:06 +01:00
f6e4e98965 add basic download test
Some checks failed
Publish Docker Image / docker (push) Has been cancelled
2023-07-12 14:16:41 +01:00
f6df0f44f2 add logs
All checks were successful
Publish Docker Image / docker (push) Successful in 1m25s
2023-07-12 14:06:48 +01:00
8cd0ff0a46 start work on auto downloading the public directory images
All checks were successful
Publish Docker Image / docker (push) Successful in 1m25s
2023-07-12 14:02:33 +01:00
4 changed files with 34 additions and 3 deletions

@ -3,6 +3,9 @@ FROM node:lts-slim
ENV NODE_ENV=production ENV NODE_ENV=production
WORKDIR /usr/src/app WORKDIR /usr/src/app
RUN apt update
RUN DEBIAN_FRONTEND=noninteractive apt install wget -y
# Copy package.json and package-lock.json separately to fully utilize Docker layer caching # Copy package.json and package-lock.json separately to fully utilize Docker layer caching
COPY package.json ./ COPY package.json ./
COPY package-lock.json ./ COPY package-lock.json ./
@ -24,4 +27,4 @@ ENV NODE_ENV=production
EXPOSE 3000 EXPOSE 3000
# Start the app # Start the app
CMD ["npm", "start"] CMD ["bash", "start.sh"]

@ -14,4 +14,4 @@ services:
- 3000:3000 - 3000:3000
volumes: volumes:
- ./config.json:/usr/src/app/config.json:ro # The application config (Must be created before starting the service) - ./config.json:/usr/src/app/config.json:ro # The application config (Must be created before starting the service)
#- ./public:/usr/src/app/public:ro # Used for public facing images (uncomment if you are using your own images - see the public directory) - ./public:/usr/src/app/public:rw # Used for public facing images (eg: avatar and background)

@ -1,6 +1,6 @@
{ {
"name": "simple-links", "name": "simple-links",
"version": "0.1.6", "version": "0.1.7",
"private": false, "private": false,
"scripts": { "scripts": {
"dev": "next dev", "dev": "next dev",

28
start.sh Normal file

@ -0,0 +1,28 @@
workDir=/usr/src/app
baseUrl=https://git.fascinated.cc/Fascinated/simple-links/raw/branch/master/public/
toDownload=("avatar.webp" "background.jpg")
echo "Checking if files need to be downloaded"
if [ -z "$(ls -A $workDir/public)" ]; then
echo "Some files are missing, downloading them"
if [ ! -w "$workDir" ]; then
# TODO: fix this. it doesn't seem to be working?
echo "The directory \"$workDir\" is not writeable, unable to download files. Please check your docker compose for :ro and set it to :rw"
fi
for item in "${toDownload[@]}"
do
dir=$workDir/public/$item
if [ ! -e "$dir" ]; then
echo "Downloading $item to directory $dir"
wget -q -P $dir $baseUrl$item
echo "Done"
fi
done
echo "Finished downloading files!"
else
echo "All files are already present, no need to download"
fi
echo "Starting Simple Links..."
npm start