Skip to content

Commit

Permalink
Add dynamic deployment for frontend.
Browse files Browse the repository at this point in the history
  • Loading branch information
daemontus committed Nov 16, 2023
1 parent 32c6a40 commit 91005aa
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
4 changes: 4 additions & 0 deletions frontend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@ FROM nginx:1.24.0

COPY nginx.conf /etc/nginx/nginx.conf
COPY ./dist /www
COPY startup.sh .
RUN chmod +x ./startup.sh

CMD /bin/bash -c "./startup.sh"
2 changes: 1 addition & 1 deletion frontend/src/services/base.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import axios from "axios";

const axiosInstance = axios.create({
baseURL: 'http://localhost:3001',
baseURL: '${BACKEND_URL}',
});

export default axiosInstance;
15 changes: 15 additions & 0 deletions frontend/startup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

folder_path="/www/assets"

file_path=$(find "$folder_path" -type f -name "*.js" -print -quit)

if [ -n "$file_path" ]; then
envsubst '${BACKEND_URL}' < "$file_path" > tmp.js
mv tmp.js "$file_path"
echo "URL substituted."
else
echo "No JavaScript file found."
fi

nginx -g 'daemon off;'

0 comments on commit 91005aa

Please sign in to comment.