質問編集履歴

1

code chnaged

2022/07/28 07:31

投稿

alizona
alizona

スコア126

test CHANGED
File without changes
test CHANGED
@@ -5,6 +5,52 @@
5
5
  localで open-cvをダウンロードしたときは1分ほどだったと記憶しているのですが、何かアドバイスいただけないでしょうか?
6
6
  試行錯誤して、5時間ほどかかってしまいました。
7
7
  ![](https://ddjkaamml8q8x.cloudfront.net/questions/2022-07-28/978e2700-4315-4152-a348-9d33d55bfa27.png)
8
+ ```変更後のdockerfile
9
+
10
+ FROM python:3.8.0
11
+
12
+
13
+ # Adding backend directory to make absolute filepaths consistent across services
14
+ WORKDIR /app/backend
15
+
16
+ # Install Python dependencies
17
+ COPY requirements.txt /app/backend
18
+
19
+ RUN apt-get update && apt-get upgrade -y
20
+ RUN pip install --upgrade pip
21
+ RUN pip install --upgrade setuptools
22
+
23
+ # OpenCV
24
+ RUN apt-get install -y libgl1-mesa-glx libglib2.0-0 libsm6 libxrender1 libxext6
25
+ RUN pip install opencv-python
26
+ RUN pip install opencv-contrib-python
27
+
28
+ #docker imageを alpine から python:3.8に変更したので、
29
+ #このRUNのapk が使えないためコードを変更しなくてはいけない
30
+ RUN \
31
+ apk add bash && \
32
+ apk add --no-cache postgresql-libs && \
33
+ apk add --no-cache --virtual .build-deps gcc musl-dev postgresql-dev && \
34
+ apk add build-base libffi-dev && \
35
+ pip3 install --upgrade pip -r requirements.txt && \
36
+ apk --purge del .build-deps
37
+
38
+
39
+ # Add the rest of the code
40
+ COPY . /app/backend
41
+ COPY ./scripts/ /app/
42
+
43
+ # Make port 8000 available for the app
44
+ ENV PORT 8000
45
+ EXPOSE 8000
46
+
47
+ # Be sure to use 0.0.0.0 for the host within the Docker container,
48
+ # otherwise the browser won't be able to find it
49
+ RUN ["chmod", "+x", "/app/entrypoint-dev.sh"]
50
+ ENTRYPOINT [ "/app/entrypoint-dev.sh" ]
51
+ # clearn
52
+ RUN rm -rf /var/lib/apt/lists/*
53
+ ```
8
54
  ```docker
9
55
  # Use an official Python runtime as a parent image
10
56
  FROM python:3.7-alpine