Xiao commited on
Commit
73835c6
·
1 Parent(s): 6f598f2

use docker alpine

Browse files
Files changed (5) hide show
  1. .nginx/nginx.conf +19 -18
  2. Dockerfile +53 -10
  3. Dockerfile.dev +0 -0
  4. docker-compose.yaml +2 -2
  5. run_hf.sh +5 -3
.nginx/nginx.conf CHANGED
@@ -5,31 +5,32 @@ events {
5
  http {
6
  server {
7
 
8
- listen 5000;
9
 
10
  location / {
11
  # root /usr/share/nginx/html;
12
- root /app/public;
13
- index index.html index.htm;
14
- try_files $uri /index.html =404;
 
15
  }
16
 
17
  error_page 500 502 503 504 /50x.html;
18
 
19
- location /static/ {
20
- # Serve backend from port
21
- rewrite /static/(.*) /$1 break;
22
- proxy_pass http://localhost:3000;
23
- proxy_http_version 1.1;
24
- proxy_set_header Upgrade $http_upgrade;
25
- proxy_set_header Connection 'upgrade';
26
- proxy_set_header Host $host;
27
- proxy_set_header X-Real-IP $remote_addr;
28
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
29
- proxy_cache_bypass $http_upgrade;
30
- proxy_read_timeout 86400;
31
- proxy_redirect off;
32
- }
33
 
34
  location = /50x.html {
35
  root /usr/share/nginx/html;
 
5
  http {
6
  server {
7
 
8
+ listen 80;
9
 
10
  location / {
11
  # root /usr/share/nginx/html;
12
+ # root /app/public;
13
+ # index index.html index.htm;
14
+ proxy_pass http://localhost:3000;
15
+ # try_files $uri /index.html =404;
16
  }
17
 
18
  error_page 500 502 503 504 /50x.html;
19
 
20
+ # location /static/ {
21
+ # # Serve backend from port
22
+ # rewrite /static/(.*) /$1 break;
23
+ # proxy_pass http://localhost:3000;
24
+ # proxy_http_version 1.1;
25
+ # proxy_set_header Upgrade $http_upgrade;
26
+ # proxy_set_header Connection 'upgrade';
27
+ # proxy_set_header Host $host;
28
+ # proxy_set_header X-Real-IP $remote_addr;
29
+ # proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
30
+ # proxy_cache_bypass $http_upgrade;
31
+ # proxy_read_timeout 86400;
32
+ # proxy_redirect off;
33
+ # }
34
 
35
  location = /50x.html {
36
  root /usr/share/nginx/html;
Dockerfile CHANGED
@@ -1,34 +1,70 @@
1
- ARG PY_VER=3.10
2
 
3
  # Default user is 'luminlab' with uid 1000, gid 1000
4
- FROM python:${PY_VER} as lean
 
 
 
 
 
 
 
 
 
 
 
5
 
6
  # Install nginx and give permissions to 'luminlab'
7
  # See https://www.rockyourcode.com/run-docker-nginx-as-non-root-user/
8
 
9
- RUN apt-get -y update && apt-get -y install nginx
 
 
 
 
 
 
10
 
 
 
 
 
 
 
 
 
11
 
12
 
13
 
14
 
 
15
  # Set up a new user named "luminlab" with user ID 1000
16
- RUN useradd -m -u 1000 luminlab
17
  # groupadd luminlab &&\
18
  # usermod -aG luminlab luminlab
 
 
19
 
20
 
 
 
 
21
  RUN mkdir -p /var/cache/nginx \
22
  /var/log/nginx \
23
  /var/lib/nginx
24
- RUN touch /var/run/nginx.pid
25
- # RUN touch /run/nginx.pid
 
 
 
26
 
27
 
28
  RUN chown -R luminlab /var/cache/nginx \
29
  /var/log/nginx \
30
  /var/lib/nginx \
31
- /var/run/nginx.pid
 
 
 
32
  # RUN chmod 777 /var/cache/nginx /var/run /var/log/nginx
33
 
34
  # COPY --chown=luminlab .nginx/nginx.conf /etc/nginx/conf.d/default.conf
@@ -49,17 +85,21 @@ COPY --chown=luminlab .nginx/nginx.conf /etc/nginx/nginx.conf
49
  # RUN mkdir $HOME/app
50
 
51
  # 1. For build React app
52
- FROM node:16-slim AS node
53
 
54
  # Set working directory
55
- WORKDIR /app
56
 
57
  #
58
  COPY package.json /app/package.json
59
  COPY package-lock.json /app/package-lock.json
60
 
 
 
 
 
61
  # Same as npm install
62
  RUN npm ci
 
63
 
64
  # COPY --chown=luminlab:luminlab . .
65
 
@@ -97,7 +137,7 @@ FROM lean AS prod
97
 
98
 
99
 
100
- COPY --chown=luminlab --from=node /app ./app
101
  # Remove default nginx static assets
102
  # RUN rm -rf ./*
103
 
@@ -107,6 +147,9 @@ COPY --chown=luminlab --from=node /app ./app
107
  WORKDIR /app
108
 
109
  COPY --chown=luminlab ./run_hf.sh /app/run_hf.sh
 
 
 
110
  RUN chmod 777 /app/run_hf.sh
111
 
112
 
 
 
1
 
2
  # Default user is 'luminlab' with uid 1000, gid 1000
3
+ # FROM node:16-alpine AS lean
4
+ FROM node:16-alpine3.18 AS lean
5
+ ARG USERNAME=luminlab
6
+ ARG GROUPNAME=${USERNAME}
7
+ ARG USER_UID=1000
8
+ ARG USER_GID=${USER_UID}
9
+ ARG CURR_GROUPNAME=node
10
+ ARG CURR_USERNAME=node
11
+
12
+ # ARG PY_VER=3.10
13
+
14
+ # FROM python:${PY_VER} as lean
15
 
16
  # Install nginx and give permissions to 'luminlab'
17
  # See https://www.rockyourcode.com/run-docker-nginx-as-non-root-user/
18
 
19
+ #ubuntu
20
+ # RUN apt-get update && apt-get install -y python3.9 python3.9-dev
21
+ USER root
22
+
23
+ # RUN apt-get -y install nginx
24
+ #alpine
25
+ RUN apk update && apk upgrade && apk add --update python3 py3-pip
26
 
27
+ RUN apk add --no-cache --upgrade bash
28
+ #install command service
29
+ RUN apk add openrc --no-cache
30
+ #install command usermod
31
+ RUN apk add --update shadow
32
+ #for local checking network
33
+ RUN apk --no-cache add curl
34
+ RUN apk add --update nginx
35
 
36
 
37
 
38
 
39
+ #ubuntu
40
  # Set up a new user named "luminlab" with user ID 1000
41
+ # RUN useradd -m -u 1000 luminlab
42
  # groupadd luminlab &&\
43
  # usermod -aG luminlab luminlab
44
+ #alpine
45
+ # RUN addgroup -S luminlab && adduser -S luminlab -G luminlab
46
 
47
 
48
+ RUN groupmod -n ${GROUPNAME} ${CURR_GROUPNAME}
49
+ RUN usermod -g ${GROUPNAME} --login ${USERNAME} ${CURR_USERNAME}
50
+
51
  RUN mkdir -p /var/cache/nginx \
52
  /var/log/nginx \
53
  /var/lib/nginx
54
+ RUN touch /var/run/nginx/nginx.pid
55
+ #ubuntu
56
+ # RUN touch /run/nginx/nginx.pid
57
+ #alpine
58
+ RUN touch /run/nginx/nginx.pid
59
 
60
 
61
  RUN chown -R luminlab /var/cache/nginx \
62
  /var/log/nginx \
63
  /var/lib/nginx \
64
+ #alpine
65
+ /var/run/nginx/nginx.pid
66
+ #ubuntu
67
+ # /var/run/nginx.pid
68
  # RUN chmod 777 /var/cache/nginx /var/run /var/log/nginx
69
 
70
  # COPY --chown=luminlab .nginx/nginx.conf /etc/nginx/conf.d/default.conf
 
85
  # RUN mkdir $HOME/app
86
 
87
  # 1. For build React app
88
+ FROM lean AS dev
89
 
90
  # Set working directory
 
91
 
92
  #
93
  COPY package.json /app/package.json
94
  COPY package-lock.json /app/package-lock.json
95
 
96
+ COPY . /app
97
+
98
+ WORKDIR /app
99
+
100
  # Same as npm install
101
  RUN npm ci
102
+ RUN mkdir node_modules/.cache && chmod -R 777 node_modules/.cache
103
 
104
  # COPY --chown=luminlab:luminlab . .
105
 
 
137
 
138
 
139
 
140
+ COPY --chown=luminlab --from=dev /app /app
141
  # Remove default nginx static assets
142
  # RUN rm -rf ./*
143
 
 
147
  WORKDIR /app
148
 
149
  COPY --chown=luminlab ./run_hf.sh /app/run_hf.sh
150
+ EXPOSE 3000
151
+ EXPOSE 80
152
+
153
  RUN chmod 777 /app/run_hf.sh
154
 
155
 
Dockerfile.dev ADDED
File without changes
docker-compose.yaml CHANGED
@@ -10,10 +10,10 @@ services:
10
  user: 1000:1000
11
  # user: root
12
  ports:
13
- - "80:3000"
14
  - "3000:3000"
15
  volumes:
16
  - ./run_hf.sh:/app/run_hf.sh
17
- # - .nginx/nginx.conf:/etc/nginx/nginx.conf
18
 
19
 
 
10
  user: 1000:1000
11
  # user: root
12
  ports:
13
+ - "80:80"
14
  - "3000:3000"
15
  volumes:
16
  - ./run_hf.sh:/app/run_hf.sh
17
+ - .nginx/nginx.conf:/etc/nginx/nginx.conf
18
 
19
 
run_hf.sh CHANGED
@@ -1,6 +1,8 @@
1
  #!/bin/bash
2
-
3
- # nginx -g daemon off;
4
  service nginx start
 
 
 
5
 
6
- sleep 1h
 
1
  #!/bin/bash
2
+ echo starting daemos
 
3
  service nginx start
4
+ # nginx -g "daemon off;"
5
+ echo starting nmp
6
+ npm start
7
 
8
+ echo done!!!