Add docker run script to change api url on startup
This commit is contained in:
parent
38c7e4b3c2
commit
9fdbcd56cf
2 changed files with 19 additions and 4 deletions
|
@ -8,9 +8,7 @@ COPY . ./
|
||||||
RUN \
|
RUN \
|
||||||
# Build the frontend
|
# Build the frontend
|
||||||
yarn install --frozen-lockfile && \
|
yarn install --frozen-lockfile && \
|
||||||
yarn run build && \
|
yarn run build
|
||||||
# Override config
|
|
||||||
sed -i 's/http\:\/\/localhost\:3456\/api\/v1/\/api\/v1/g' dist/index.html
|
|
||||||
|
|
||||||
# Stage 2: copy
|
# Stage 2: copy
|
||||||
FROM nginx
|
FROM nginx
|
||||||
|
@ -22,8 +20,11 @@ RUN apt-get update && apt-get install -y apt-utils openssl && \
|
||||||
openssl x509 -req -days 3650 -in /etc/nginx/ssl/dummy.csr -signkey /etc/nginx/ssl/dummy.key -out /etc/nginx/ssl/dummy.crt
|
openssl x509 -req -days 3650 -in /etc/nginx/ssl/dummy.csr -signkey /etc/nginx/ssl/dummy.key -out /etc/nginx/ssl/dummy.crt
|
||||||
|
|
||||||
COPY nginx.conf /etc/nginx/nginx.conf
|
COPY nginx.conf /etc/nginx/nginx.conf
|
||||||
|
COPY run.sh /run.sh
|
||||||
|
|
||||||
# copy compiled files from stage 1
|
# copy compiled files from stage 1
|
||||||
COPY --from=compile-image /build/dist /usr/share/nginx/html
|
COPY --from=compile-image /build/dist /usr/share/nginx/html
|
||||||
|
|
||||||
LABEL maintainer="maintainers@vikunja.io"
|
LABEL maintainer="maintainers@vikunja.io"
|
||||||
|
|
||||||
|
CMD "/run.sh"
|
14
run.sh
Executable file
14
run.sh
Executable file
|
@ -0,0 +1,14 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# This shell script sets the api url based on an environment variable and starts nginx in foreground.
|
||||||
|
|
||||||
|
if [ -z "$VIKUNJA_API_URL" ]; then
|
||||||
|
VIKUNJA_API_URL="/api/v1"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Escape the variable to prevent sed from complaining
|
||||||
|
VIKUNJA_API_URL=$(echo $VIKUNJA_API_URL |sed 's/\//\\\//g')
|
||||||
|
|
||||||
|
sed -i "s/http\:\/\/localhost\:3456\/api\/v1/$VIKUNJA_API_URL/g" /usr/share/nginx/html/index.html
|
||||||
|
|
||||||
|
nginx -g "daemon off;"
|
Loading…
Reference in a new issue