Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +58 -58
Dockerfile
CHANGED
@@ -1,58 +1,58 @@
|
|
1 |
-
FROM nikolaik/python-nodejs:python3.11-nodejs21
|
2 |
-
|
3 |
-
# Install nginx
|
4 |
-
USER root
|
5 |
-
RUN apt-get -y update && apt-get -y install nginx
|
6 |
-
|
7 |
-
# Setup directory structure for Nginx
|
8 |
-
RUN mkdir -p /var/cache/nginx \
|
9 |
-
/var/log/nginx \
|
10 |
-
/var/lib/nginx \
|
11 |
-
/var/www/html \
|
12 |
-
/usr/share/nginx/html
|
13 |
-
RUN touch /var/run/nginx.pid
|
14 |
-
|
15 |
-
# Give permissions to 'pn' user for Nginx and static files directory
|
16 |
-
RUN chown -R pn:pn /var/cache/nginx \
|
17 |
-
/var/log/nginx \
|
18 |
-
/var/lib/nginx \
|
19 |
-
/var/run/nginx.pid \
|
20 |
-
/var/www/html \
|
21 |
-
/usr/share/nginx/html
|
22 |
-
|
23 |
-
# Switch back to the 'pn' user for installing dependencies and building the app
|
24 |
-
USER pn
|
25 |
-
ENV HOME=/home/pn \
|
26 |
-
PATH=/home/pn/.local/bin:$PATH
|
27 |
-
|
28 |
-
WORKDIR $HOME/app
|
29 |
-
|
30 |
-
# Copy the requirements and install Python dependencies
|
31 |
-
COPY --chown=pn requirements.txt requirements.txt
|
32 |
-
RUN pip install -r requirements.txt
|
33 |
-
|
34 |
-
# Handling frontend setup: Install dependencies and build
|
35 |
-
COPY --chown=pn frontend frontend
|
36 |
-
WORKDIR $HOME/app/frontend
|
37 |
-
RUN npm install
|
38 |
-
RUN npm run build
|
39 |
-
RUN ls
|
40 |
-
RUN pwd
|
41 |
-
COPY --chown=pn dist/. /usr/share/nginx/html
|
42 |
-
# Switch back to app directory
|
43 |
-
USER pn
|
44 |
-
WORKDIR $HOME/app
|
45 |
-
|
46 |
-
COPY --chown=pn backend backend
|
47 |
-
|
48 |
-
COPY --chown=pn default.conf /etc/nginx/conf.d/default.conf
|
49 |
-
|
50 |
-
# Prepare the entrypoint script
|
51 |
-
COPY --chown=pn run.sh run.sh
|
52 |
-
|
53 |
-
RUN chmod +x run.sh
|
54 |
-
|
55 |
-
# Expose the port 8080
|
56 |
-
EXPOSE 7860
|
57 |
-
|
58 |
-
CMD ["bash", "run.sh"]
|
|
|
1 |
+
FROM nikolaik/python-nodejs:python3.11-nodejs21
|
2 |
+
|
3 |
+
# Install nginx
|
4 |
+
USER root
|
5 |
+
RUN apt-get -y update && apt-get -y install nginx
|
6 |
+
|
7 |
+
# Setup directory structure for Nginx
|
8 |
+
RUN mkdir -p /var/cache/nginx \
|
9 |
+
/var/log/nginx \
|
10 |
+
/var/lib/nginx \
|
11 |
+
/var/www/html \
|
12 |
+
/usr/share/nginx/html
|
13 |
+
RUN touch /var/run/nginx.pid
|
14 |
+
|
15 |
+
# Give permissions to 'pn' user for Nginx and static files directory
|
16 |
+
RUN chown -R pn:pn /var/cache/nginx \
|
17 |
+
/var/log/nginx \
|
18 |
+
/var/lib/nginx \
|
19 |
+
/var/run/nginx.pid \
|
20 |
+
/var/www/html \
|
21 |
+
/usr/share/nginx/html
|
22 |
+
|
23 |
+
# Switch back to the 'pn' user for installing dependencies and building the app
|
24 |
+
USER pn
|
25 |
+
ENV HOME=/home/pn \
|
26 |
+
PATH=/home/pn/.local/bin:$PATH
|
27 |
+
|
28 |
+
WORKDIR $HOME/app
|
29 |
+
|
30 |
+
# Copy the requirements and install Python dependencies
|
31 |
+
COPY --chown=pn requirements.txt requirements.txt
|
32 |
+
RUN pip install -r requirements.txt
|
33 |
+
|
34 |
+
# Handling frontend setup: Install dependencies and build
|
35 |
+
COPY --chown=pn frontend frontend
|
36 |
+
WORKDIR $HOME/app/frontend
|
37 |
+
RUN npm install
|
38 |
+
RUN npm run build
|
39 |
+
RUN ls
|
40 |
+
RUN pwd
|
41 |
+
COPY --chown=pn $HOME/app/frontend/dist/. /usr/share/nginx/html
|
42 |
+
# Switch back to app directory
|
43 |
+
USER pn
|
44 |
+
WORKDIR $HOME/app
|
45 |
+
|
46 |
+
COPY --chown=pn backend backend
|
47 |
+
|
48 |
+
COPY --chown=pn default.conf /etc/nginx/conf.d/default.conf
|
49 |
+
|
50 |
+
# Prepare the entrypoint script
|
51 |
+
COPY --chown=pn run.sh run.sh
|
52 |
+
|
53 |
+
RUN chmod +x run.sh
|
54 |
+
|
55 |
+
# Expose the port 8080
|
56 |
+
EXPOSE 7860
|
57 |
+
|
58 |
+
CMD ["bash", "run.sh"]
|