client/docker: improved Dockerfile
This commit is contained in:
parent
2af304b844
commit
6da18036a4
3 changed files with 35 additions and 15 deletions
|
@ -11,19 +11,21 @@ ARG CLIENT_BUILD_ARGS=""
|
|||
RUN BASE_URL="__BASEURL__" node build.js --gzip ${CLIENT_BUILD_ARGS}
|
||||
|
||||
|
||||
FROM nginx:alpine
|
||||
FROM scratch as approot
|
||||
|
||||
COPY docker-start.sh /
|
||||
|
||||
WORKDIR /etc/nginx
|
||||
COPY nginx.conf.docker ./nginx.conf
|
||||
|
||||
WORKDIR /var/www
|
||||
|
||||
RUN \
|
||||
# Create init file
|
||||
echo "#!/bin/sh" >> /init && \
|
||||
echo 'sed -i "s|__BACKEND__|${BACKEND_HOST}|" /etc/nginx/nginx.conf' >> /init && \
|
||||
echo 'sed -i "s|__BASEURL__|${BASE_URL:-/}|g" /var/www/index.htm /var/www/manifest.json' >> /init && \
|
||||
echo 'exec nginx' >> /init && \
|
||||
chmod a+x /init
|
||||
|
||||
CMD ["/init"]
|
||||
VOLUME ["/data"]
|
||||
|
||||
COPY nginx.conf.docker /etc/nginx/nginx.conf
|
||||
COPY --from=builder /opt/app/public/ .
|
||||
|
||||
|
||||
FROM nginx:alpine
|
||||
|
||||
RUN apk --no-cache add dumb-init
|
||||
COPY --from=approot / /
|
||||
|
||||
CMD ["/docker-start.sh"]
|
||||
VOLUME ["/data"]
|
||||
|
|
11
client/docker-start.sh
Executable file
11
client/docker-start.sh
Executable file
|
@ -0,0 +1,11 @@
|
|||
#!/usr/bin/dumb-init /bin/sh
|
||||
|
||||
# Integrate environment variables
|
||||
sed -i "s|__BACKEND__|${BACKEND_HOST}|" \
|
||||
/etc/nginx/nginx.conf
|
||||
sed -i "s|__BASEURL__|${BASE_URL:-/}|g" \
|
||||
/var/www/index.htm \
|
||||
/var/www/manifest.json
|
||||
|
||||
# Start server
|
||||
exec nginx
|
|
@ -1,4 +1,11 @@
|
|||
#!/bin/sh
|
||||
BUILD_INFO=docker-$(echo $SOURCE_COMMIT | cut -c1-7)-auto
|
||||
|
||||
CLOSEST_VER=$(git describe --tags --abbrev=0)
|
||||
if git describe --exact-match --abbrev=0 2> /dev/null; then
|
||||
BUILD_INFO="v${CLOSEST_VER}"
|
||||
else
|
||||
BUILD_INFO="v${CLOSEST_VER}-edge-$(echo $SOURCE_COMMIT | cut -c1-7)"
|
||||
fi
|
||||
|
||||
echo "Using BUILD_INFO=$BUILD_INFO"
|
||||
docker build --build-arg BUILD_INFO=$BUILD_INFO -f $DOCKERFILE_PATH -t $IMAGE_NAME .
|
||||
|
|
Loading…
Reference in a new issue