0
0
Vueframework~20 mins

Docker deployment for Vue apps - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Docker Vue Deployment Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
component_behavior
intermediate
2:00remaining
What will be the output when running this Dockerfile for a Vue app?
Consider this Dockerfile for a Vue app. What will be the final behavior of the container when started?
Vue
FROM node:18-alpine AS build
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
RUN npm run build

FROM nginx:stable-alpine
COPY --from=build /app/dist /usr/share/nginx/html
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
AThe container serves the built Vue app on port 80 using nginx.
BThe container serves the Vue app but on port 3000 instead of 80.
CThe container fails because npm install is missing in the second stage.
DThe container runs the Vue app in development mode with hot reload on port 80.
Attempts:
2 left
💡 Hint
Think about what the two stages in the Dockerfile do and what nginx serves.
📝 Syntax
intermediate
1:30remaining
Which Dockerfile snippet correctly copies the Vue build output to nginx?
You want to copy the Vue app build output from the build stage to nginx's html folder. Which COPY command is correct?
ACOPY /app/dist /usr/share/nginx/html
BCOPY --from=build /dist /usr/share/nginx/html
CCOPY --from=build /app/build /usr/share/nginx/html
DCOPY --from=build /app/dist /usr/share/nginx/html
Attempts:
2 left
💡 Hint
Remember the build output folder inside the build stage.
🔧 Debug
advanced
2:30remaining
Why does this Docker container fail to serve the Vue app?
Given this Dockerfile snippet, the container starts but shows a 404 error when accessed: FROM node:18-alpine AS build WORKDIR /app COPY package*.json ./ RUN npm install COPY . . RUN npm run build FROM nginx:stable-alpine COPY --from=build /app /usr/share/nginx/html EXPOSE 80 CMD ["nginx", "-g", "daemon off;"]
AThe EXPOSE 80 command is missing, so port 80 is not open.
BThe npm install command is missing, so build fails silently.
CThe entire /app folder is copied instead of only /app/dist, so nginx serves wrong files.
DThe CMD command is incorrect and nginx never starts.
Attempts:
2 left
💡 Hint
Check what nginx expects to serve and what files are copied.
state_output
advanced
1:30remaining
What environment variable should you set to change the base URL in a Vue app Docker build?
You want your Vue app to work correctly behind a subpath like /myapp/. Which environment variable should you set during build to adjust the base URL?
AVUE_APP_PUBLIC_PATH
BBASE_URL
CPUBLIC_PATH
DVUE_APP_BASE_URL
Attempts:
2 left
💡 Hint
Check Vue CLI documentation about base URL configuration.
🧠 Conceptual
expert
3:00remaining
Why use a multi-stage Docker build for Vue apps instead of a single stage?
What is the main advantage of using a multi-stage Dockerfile with a build stage and a separate nginx stage for deploying Vue apps?
AIt reduces the final image size by excluding development dependencies and build tools.
BIt allows running the Vue app in development mode inside the container.
CIt enables hot module replacement in production containers.
DIt automatically updates the Vue app when source files change.
Attempts:
2 left
💡 Hint
Think about what files are needed to run the app versus build it.