Hello all,
I am new to Docker and Github.
I have forked the famous repo of robot-shop into my own Github account:
After I have done it I have changed some files locally. Every time I have done docker-compose pull and docker-compose up I was getting the image from the main instana Github. Therefore, I have entered to the Dockerfile in order to change a folder that it will copy directly from my local folder.
This is the Dockerfile, what I have changed it is bold is only the last line, only one folder!
FROM alpine AS build
ARG KEY
WORKDIR /instana
RUN apk add --update --no-cache curl
ENV ARTI_PATH='https://artifact-public.instana.io/artifactory/shared/com/instana/nginx_tracing/'
RUN if [ -n "$KEY" ]; then \
sensor_version=$(curl --user "_:$KEY" ${ARTI_PATH} | grep -o '>[0-9]\+\.[0-9]\+\.[0-9]\+'| cut -f 2 -d '>'|sort -V|tail -1 ); \
echo "Downloading sensor version ${sensor_version} for Nginx version 1.21.6" ; \
curl \
--output instana.zip \
--user "_:$KEY" \
${ARTI_PATH}/${sensor_version}/linux-amd64-glibc-nginx-1.21.6.zip && \
unzip instana.zip && \
mv glibc-libinstana_sensor.so libinstana_sensor.so && \
mv glibc-nginx-1.21.6-ngx_http_ot_module.so ngx_http_opentracing_module.so; \
else echo "KEY not provided. Not adding tracing"; \
touch dummy.so; \
fi
FROM nginx:1.21.6
EXPOSE 8080
ENV CATALOGUE_HOST=catalogue \
USER_HOST=user \
CART_HOST=cart \
SHIPPING_HOST=shipping \
PAYMENT_HOST=payment \
RATINGS_HOST=ratings \
INSTANA_SERVICE_NAME=nginx-web
# Instana tracing
COPY --from=build /instana/*.so /tmp/
COPY entrypoint.sh /root/
ENTRYPOINT ["/root/entrypoint.sh"]
COPY default.conf.template /etc/nginx/conf.d/default.conf.template
COPY /home/thesonics/robot-shop/web/static /usr/share/nginx/html
I have run a build without a catch in order to build it again correctly.
Sadly, I got the following error:
> [stage-1 5/5] COPY /home/thesonics/robot-shop/web/static /usr/share/nginx/html:
------
failed to compute cache key: "/home/thesonics/robot-shop/web/static" not found: not found
ERROR: Service 'web' failed to build : Build failed
Is there an option just to change part of the Dockerfile?
If not, how can I create one, I am very new at this tech.
so the context relative to the Dockerfile is web, then the Dockerfile in this folder should use the relative path as first arguement of COPY. This is what you did, this is what should have worked…
No idea then. I am afraid this is for somone else to answer.
There is one more thing that commes to mind. If things don’t make sense, usualy the snap version of docker is installed. Please use following command to check if it’s the case:
me@node:~$ snap list docker
error: no matching snaps installed
If you get a different output than I did, please remove the snap package and install the docker engine (!=Docker Desktop) package from docker’s own repositories (see: Install Docker Engine | Docker Documentation)!
What error exactly? @meyay may be right with suspecting snap, but “an error” is never enough information to help you. We are just sometimes lucky to figure it out. “An error” can be related to the COPY instruction but it can also be related to something else after the COPY. It is always a good practice to share error messages again even if you are sure that the message is the same so we can all focus on something else.
An other suggestion. When you are not sure what is in your actual build context, you can always copy copy everything and see what it will copy to the image:
COPY . /debug
If it works, you can run a container from the image and check the files in /debug
It is however not completely harmless, since if you don’t know what the context is, it can be your root directory (not likely, based on the docker compose file)