andreped commited on
Commit
a4992b2
·
2 Parent(s): 677b700 897a2bc

Merge pull request #4 from andreped/fix-docker-permissions

Browse files
Files changed (2) hide show
  1. Dockerfile +11 -10
  2. nginx.conf +2 -1
Dockerfile CHANGED
@@ -1,10 +1,7 @@
1
  FROM nginx:alpine
2
 
3
- # Install shadow package to get useradd command
4
- RUN apk add --no-cache shadow
5
-
6
- # Install wget
7
- RUN apk add --no-cache wget
8
 
9
  # Add a new user
10
  RUN useradd -m -u 1000 user
@@ -16,20 +13,24 @@ WORKDIR /app
16
  COPY index.html /usr/share/nginx/html
17
  COPY nginx.conf /etc/nginx/nginx.conf
18
 
19
- # Download test data
20
  RUN wget https://github.com/andreped/wsi-visualization-demo/releases/download/sample-data/test-sample.zip \
21
  && unzip test-sample.zip -d /usr/share/nginx/html \
22
  && rm test-sample.zip
23
 
24
- # Download OpenSeadragon
25
  RUN wget https://github.com/openseadragon/openseadragon/releases/download/v5.0.0/openseadragon-bin-5.0.0.zip \
26
  && unzip openseadragon-bin-5.0.0.zip -d /usr/share/nginx/html \
27
  && rm openseadragon-bin-5.0.0.zip
28
 
29
- RUN ls -la /usr/share/nginx/html
 
30
 
31
  # Expose port 7860
32
  EXPOSE 7860
33
 
34
- # Start nginx as root but serve files as non-root user
35
- CMD ["sh", "-c", "nginx -g 'daemon off;'"]
 
 
 
 
1
  FROM nginx:alpine
2
 
3
+ # Install necessary packages
4
+ RUN apk add --no-cache shadow wget unzip
 
 
 
5
 
6
  # Add a new user
7
  RUN useradd -m -u 1000 user
 
13
  COPY index.html /usr/share/nginx/html
14
  COPY nginx.conf /etc/nginx/nginx.conf
15
 
16
+ # Download and uncompress test data
17
  RUN wget https://github.com/andreped/wsi-visualization-demo/releases/download/sample-data/test-sample.zip \
18
  && unzip test-sample.zip -d /usr/share/nginx/html \
19
  && rm test-sample.zip
20
 
21
+ # Download and uncompress OpenSeadragon
22
  RUN wget https://github.com/openseadragon/openseadragon/releases/download/v5.0.0/openseadragon-bin-5.0.0.zip \
23
  && unzip openseadragon-bin-5.0.0.zip -d /usr/share/nginx/html \
24
  && rm openseadragon-bin-5.0.0.zip
25
 
26
+ # Change ownership of nginx directories to the new user
27
+ RUN chown -R user:user /var/cache/nginx /var/run /var/log/nginx /usr/share/nginx/html
28
 
29
  # Expose port 7860
30
  EXPOSE 7860
31
 
32
+ # Switch to the new user
33
+ USER user
34
+
35
+ # Start nginx
36
+ CMD ["nginx", "-g", "daemon off;"]
nginx.conf CHANGED
@@ -1,4 +1,5 @@
1
- user user;
 
2
  events {
3
  worker_connections 1024;
4
  }
 
1
+ pid /tmp/nginx.pid;
2
+
3
  events {
4
  worker_connections 1024;
5
  }