-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Phase07: containerizing tracegoute
with docker
#4
base: main
Are you sure you want to change the base?
Conversation
phase07/docker-compose.yml
Outdated
@@ -0,0 +1,32 @@ | |||
version: '3.8' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
چرا از دایرکتیو ورژن استفاده کردید؟
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
سلام
چندجا دیده بودیم فکر کردیم لازمه
حالا الان نگاهکردیم زده بود توی V2 نیاز نیست.
phase07/docker-compose.yml
Outdated
redis: | ||
restart: always | ||
image: redis:6.0 | ||
ports: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
چرا پورت ردیس اکسپوز شده؟
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
همون اول اینو گذاشتیم که ببینیم volume ای که ساخته میشه به درستی کار میکنه یا نه. و از خود سیستم به پورتش متصل میشدیم و داده ها رو میخوندیم ولی بعد هنگام پوش کردن فراموش کردیم حذفش کنیم.
phase07/tracegouteApi/Dockerfile
Outdated
RUN go mod download | ||
|
||
COPY . . | ||
#COPY */*.go . |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
چرا اینجا کامنت شده؟
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
آها اینو حضوری با هم صحبت کردیم. حالا باز دیدیمتون صحبت میکنیم.
|
||
RUN chown -R appuser /app | ||
|
||
USER appuser |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
در بیلد مولتی استیج، استیج بیلد دور انداخته میشه و نیازی به تغییر یوزر نیست. اما برای ساخت یوزر بهتره که در حالتی یوزر رو بسازید که UID و GID بزرگتر از 10000 باشه.
برای بست پرکتیسها به این دو تا لینک نگاه بندازید:
https://sysdig.com/blog/dockerfile-best-practices/
https://github.com/dnaprawa/dockerfile-best-practices?tab=readme-ov-file#run-as-a-non-root-user
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
اگر منظور این هست که به صورت دستی براش UID مشخص کنیم ما ابتدا همین کار رو کرده بودیم ولی داخل همین لینکی که فرستادید تحت این عنوان 1.2 Don’t bind to a specific UID گفته شده که به صورت دستی UID مشخص نکنیم. حالا نمیدونیم آیا میشه بگیم از یه عددی بیشتر UID بده یا نه.
phase07/tracegouteApi/Dockerfile
Outdated
RUN CGO_ENABLED=0 GOOS=linux go build -o ./tracegoute | ||
|
||
#runner | ||
FROM alpine:3.14 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
چرا از scratch استفاده نشده؟
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
نمیدونستیم چنین چیزی هست فکر میکردیم alpine به اندازه کافی سبک هست. حالا عوضش میکنیم.
phase07/tracegouteApi/Dockerfile
Outdated
|
||
WORKDIR /app | ||
|
||
COPY --from=builder --chown=root:root app/.env ./.env |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
فایل .env رو اینجا نیازی نیست که بدید.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ساختار ابتدایی برنامه ی go ای که نوشتیم نیازمند دریافت این فایل هست برای همین در صورتی که این فایل کپی نشه برنامه با موفقیت اجرا نمیشه. ولی حالا تغییراتی داخل برنامه ی go میدیم که مشکل حل میشه.
No description provided.