swsnu / swppfall2021

Learning Software Engineering By Building Web Services
28 stars 19 forks source link

[Deployment] Question about frontend Dockerfile in practice session #171

Open clarkindy opened 2 years ago

clarkindy commented 2 years ago

1.

In Line 15:

RUN ln -s /etc/nginx/sites-available/nginx.conf /etc/nginx/sites-enabled/nginx.conf

When building with a modified version of this Dockerfile in my team's EC2 instance, the build process errored in the above line, mentioning that /etc/nginx/sites-enabled/nginx.conf already exists.

ln: failed to create symbolic link '/etc/nginx/sites-enabled/nginx.conf': File exists

Edit: This was because I replicated the typo in the presentation slides, which is fixed in the repo. You should change sites-enabled in Line 13 to sites-available.

- COPY nginx.conf /etc/nginx/sites-enabled/nginx.conf
+ COPY nginx.conf /etc/nginx/sites-available/nginx.conf

2.

In Line 18:

RUN cp -r build/* /usr/share/nginx/html/

Why do we use RUN here instead of COPY?

kdh0102 commented 2 years ago
  1. Can you check the Dockerfile in the practice repo? There should be a link to the file in the slide. The Dockerfile in the github repo should be right. Sorry for the inconvenience. Line 13 in the practice session file and Line 15 of your file is different. That's why you have to swap the two when making a symbolic link (ln -s ...).
  2. COPY is to copy file from your host to the container. RUN cp is to copy files inside the container.

Let me know if you need more explanations. @clarkindy

clarkindy commented 2 years ago

COPY is to copy file from your host to the container. RUN cp is to copy files inside the container.

Oh, now I understand. Thank you!