Skip to content

Commit

Permalink
Dist UI build in docker
Browse files Browse the repository at this point in the history
  • Loading branch information
PicoCreator committed Jan 10, 2020
1 parent 948a6f9 commit 453dcac
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 22 deletions.
26 changes: 13 additions & 13 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,23 @@ else
fi

#
# Applying the configuration
# Setup the UI
#
echo ">> Applying config settings"
cat "$projectDir/api/config/mailgunConfig.sample.js" | envsubst > "$projectDir/api/config/mailgunConfig.js"
cat "$projectDir/ui/config/apiconfig.sample.js" | envsubst > "$projectDir/ui/config/apiconfig.js"
echo ">> Setting up UI"

#
# Doing the required builds
#
# Clone the files
rm -rf /application/api/public/*
cp -r /application/ui-dist/ /application/api/public/

# Build the UI
cd /application/ui
npm run build
# Find and replace
find /application/api/public/ -type f -exec sed -i "s/\$\{MAILGUN_EMAIL_DOMAIN\}/$MAILGUN_EMAIL_DOMAIN/g" {} +
find /application/api/public/ -type f -exec sed -i "s/\$\{WEBSITE_DOMAIN\}/$WEBSITE_DOMAIN/g" {} +

# Export it to the api server static host
rm -rf /application/api/public/*
cp -r /application/ui/dist/* /application/api/public/
#
# Setup the API
#
echo ">> Setting up API config"
cat "application/api/config/mailgunConfig.sample.js" | envsubst > "application/api/config/mailgunConfig.js"

# Start the API
cd /application/api/
Expand Down
17 changes: 11 additions & 6 deletions dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@
#
# Base alpine image with all the various dependencies
#
# Note that the node sass is broken with
# https://github.com/nodejs/docker-node/issues/1028
#
FROM node:12-alpine AS baseimage
#
FROM node:10-alpine AS baseimage

# Install dependencies
RUN apk add --no-cache gettext
Expand Down Expand Up @@ -33,11 +36,12 @@ RUN rm -rf /application/ui/node_modules
RUN rm -rf /application/ui/dist

# Lets do the initial npm install
RUN cd /application/ui && ls && npm install --production
RUN cd /application/api && ls && npm install --production
RUN cd /application/ui && ls && npm install
RUN cd /application/api && ls && npm install

# Lets do the initial builds
RUN cd /application/ui && npm build
# Lets do the UI build
RUN cp /application/ui/config/apiconfig.sample.js /application/ui/config/apiconfig.js
RUN cd /application/ui && npm run build

#
#
Expand All @@ -47,7 +51,8 @@ RUN cd /application/ui && npm build
FROM node:12-alpine as application

# Copy over the built files
COPY --from=builder /application /application/
COPY --from=builder /application/api /application/
COPY --from=builder /application/ui/dist /application/ui-dist

# Debugging logging
RUN ls /application
Expand Down
5 changes: 2 additions & 3 deletions ui/config/apiconfig.sample.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
export default {
apiUrl: 'https://${WEBSITE_DOMAIN}/api/v1/mail',
apiUrl: '//${WEBSITE_DOMAIN}/api/v1/mail',
domain: '${MAILGUN_EMAIL_DOMAIN}'
}

}

0 comments on commit 453dcac

Please sign in to comment.