File size: 2,184 Bytes
a94a366
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# See https://hub.docker.com/r/nikolaik/python-nodejs
#     https://github.com/nikolaik/docker-python-nodejs
# Default user is 'luminlab' with uid 1000, gid 1000
FROM nikolaik/python-nodejs:python3.10-nodejs18

# Install nginx and give permissions to 'luminlab'
# See https://www.rockyourcode.com/run-docker-nginx-as-non-root-user/
USER root

RUN apt-get -y update && apt-get -y install nginx

RUN mkdir -p /var/cache/nginx \
             /var/log/nginx \
             /var/lib/nginx
RUN touch /var/run/nginx.pid

RUN chown -R luminlab:luminlab /var/cache/nginx \
                       /var/log/nginx \
                       /var/lib/nginx \
                       /var/run/nginx.pid

# syntax=docker/dockerfile:1.4

# 1. For build React app
FROM node:lts AS development

# Set working directory
WORKDIR /app

# 
COPY package.json /app/package.json
COPY package-lock.json /app/package-lock.json

# Same as npm install
RUN npm ci

COPY . /app

ENV CI=true
ENV PORT=3000

CMD [ "npm", "start" ]

FROM development AS build

RUN npm run build


FROM development as dev-envs
RUN apt-get update &&\
    apt-get install -y --no-install-recommends git

RUN useradd -s /bin/bash -m vscode &&\
    groupadd docker &&\
    usermod -aG docker vscode 

# install Docker tools (cli, buildx, compose)
COPY --from=gloursdocker/docker / /
CMD [ "npm", "start" ]

# 2. For Nginx setup
FROM nginx:alpine

# Copy config nginx
COPY --from=build /app/.nginx/nginx.conf /etc/nginx/conf.d/default.conf

WORKDIR /usr/share/nginx/html

# Remove default nginx static assets
RUN rm -rf ./*

# Copy static assets from builder stage
COPY --from=build /app/build .

# # Containers run nginx with global directives and daemon off
ENTRYPOINT ["nginx", "-g", "daemon off;"]


# Install dependencies and build app as non-root
# USER luminlab
# ENV HOME=/home/luminlab \
#     PATH=/home/luminlab/.local/bin:$PATH

# RUN mkdir $HOME/app

# WORKDIR $HOME/app

# COPY --chown=pn requirements.txt requirements.txt
# RUN pip install --no-cache-dir -r requirements.txt

# # Copy nginx configuration
# COPY --chown=luminlab nginx.conf /etc/nginx/sites-available/default

# COPY --chown=luminlab . .

# CMD ["bash", "run.sh"]