Hi there, I'm trying to build a node docker image ...
# general
a
Hi there, I'm trying to build a node docker image through Pants but I'm having trouble understanding the right way to do it. Can someone help guide me?
Copy code
// services/frontend/BUILD 

docker_image(name="front", dependencies=[":public", ":package", ":config"])

resources(
    name="package",
    sources=["services/frontend/package*.json"],
)
resource(
    name="config",
    source="services/frontend/vue.config.js"
)

resources(
    name="public",
    sources=["services/frontend/public/*"],
)
Copy code
// services/frontend/Dockerfile 
FROM node:17.1.0 as build-stage

WORKDIR /app
COPY package*.json ./
RUN npm install

COPY public .
COPY package.json ./
COPY vue.config.js ./

RUN npm run build
Copy code
// General Project Structure 

services
    - frontend / 
        - public/
              - data/ 
              - fonts/
        - BUILD 
        - Dockerfile
        - package.json
        - vue.config.js 
src 
   - js / 
   - python / 
BUILD
pants.toml 
requirements.txt
I keep encountering:
Copy code
#12 [7/8] COPY vue.config.js ./
#12 ERROR: "/vue.config.js" not found: not found

#10 [5/8] COPY public .
#10 ERROR: "/public" not found: not found

#11 [6/8] COPY package.json ./
#11 ERROR: "/package.json" not found: not found
Thanks so much
c
Hi πŸ‘‹ First, try using
files
rather than
resources
for your
docker_image
targets.
βœ… 1
πŸ‘ 1
Then, in your
Dockerfile
you need the full path to your files, that is
COPY services/frontend/…
πŸ™ 1
Feedback on this last part welcome. I started with an option where you could optionally do what you were trying to do, but there’s pitfalls here to be aware of.
a
It is successfully built, thanks for the help @curved-television-6568 πŸŽ‰
πŸ‘ 1
πŸ™ 1