I'm trying to create a dockerfile which builds my Vue application and inserts environment variables. I've combined the documentation from Vue and Redhat:
- https://v2.vuejs.org/v2/cookbook/dockerize-vuejs-app.html
- https://developers.redhat.com/blog/2021/03/04/making-environment-variables-accessible-in-front-end-containers#
Now I ended up with the following:
# build stage
FROM node:lts-alpine as build-stage
ENV JQ_VERSION=1.6
RUN wget --no-check-certificate https://github.com/stedolan/jq/releases/download/jq-${JQ_VERSION}/jq-linux64 -O /tmp/jq-linux64
RUN cp /tmp/jq-linux64 /usr/bin/jq
RUN chmod +x /usr/bin/jq
WORKDIR /app
COPY .npmrc .npmrc
COPY package*.json ./
RUN npm ci
COPY . .
RUN jq 'to_entries | map_values({ (.key) : ("$" + .key) }) | reduce .[] as $item ({}; . + $item)' ./src/config.json > ./src/config.tmp.json && mv ./src/config.tmp.json ./src/config.json
RUN npm run build
RUN rm -f .npmrc
# production stage
FROM nginx:stable-alpine as production-stage
ENV JSFOLDER=/usr/share/nginx/html/js/*.js
COPY ./infra/start-nginx.sh /usr/bin/start-nginx.sh
RUN chmod +x /usr/bin/start-nginx.sh
COPY --from=build-stage /app/dist /usr/share/nginx/html
EXPOSE 80
ENTRYPOINT [ "start-nginx.sh" ]
Building the application goes fine, but when I run docker run -it -p 8080:80 --rm --name adonis-app-1 adonis-app I get a message stating: env: can't execute 'bash': No such file or directory.
My end goal is to use a JSON file depending on the environment (dev, acc, pr) and then use those files to replace all variables in my config.json which have a value starting with $. Does anyone know why bash can't be found/executed?