'Can I use Docker arguments in the `from` flag of a Docker COPY statement?

The following is the top of my Dockerfile:

ARG VERSION=dev
ARG DEPENDENCY_VERSION=latest

# Rebuild the source code only when needed
FROM node:14-alpine AS builder
ARG DEPENDENCY_VERSION
WORKDIR /app
COPY ./web .
COPY --from=registry.gitlab.com/my-group/my-project:${DEPENDENCY_VERSION} app/node_modules ./node_modules

The pipeline fails with an error error building image: could not parse reference. Am I messing something up or arguments are not allowed inside the --from flag?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source