@@ -5,11 +5,29 @@ WORKDIR /
55# docker run -d --name khi_db -e MONGO_INITDB_ROOT_USERNAME=env.user -e MONGO_INITDB_ROOT_PASSWORD=env.password -e MONGO_INITDB_DATABASE=env.db -v mongodb_data:/data/db -p 27017:27017 mongo:latest
66RUN apt-get update && apt-get install -y supervisor sudo nodejs npm net-tools
77
8+ # ensure directories exist
9+ RUN mkdir /var/www
10+ RUN mkdir /var/www/khi
11+ RUN mkdir /var/www/project
12+
13+ # give www-data ability to run commands and interact with web-root
14+ RUN chsh -s /bin/bash www-data
15+ RUN chown -R www-data:www-data /var/www
16+
817# move production build into docker and move
918# nginx conf file into the docker
10- COPY build /var/www/khi
11- COPY package.json /var/www/khi/package.json
12- COPY .env /var/www/khi/.env
19+ COPY public /var/www/project/public
20+ COPY src /var/www/project/src
21+ COPY .env /var/www/project/.env
22+ COPY package.json /var/www/project/package.json
23+
24+ # create symlink to .env
25+ RUN ln -s /var/www/project/.env /var/www/khi/.env
26+ RUN ln -s /var/www/project/package.json /var/www/khi/package.json
27+
28+ # build react app
29+ RUN su www-data -s /bin/sh -c "cd /var/www/project && npm install . && npm run build && cp -r build/* -t /var/www/khi"
30+
1331COPY docker/khi /etc/nginx/conf.d/khi.conf
1432
1533# move backend to web root
@@ -18,9 +36,6 @@ COPY backend /var/www/khi/backend
1836# remove default nginx config
1937RUN rm /etc/nginx/conf.d/default.conf
2038
21- # give www-data ability to run commands and interact with web-root
22- RUN chsh -s /bin/bash www-data
23- RUN chown -R www-data:www-data /var/www
2439# install needed nodejs packages to allow the backend to run
2540RUN su www-data -s /bin/sh -c "cd /var/www/khi && npm install ."
2641
0 commit comments