From b3a909cebe8687572b5e11e669a2134d9aedc8ed Mon Sep 17 00:00:00 2001 From: Shiham Abdul Rahman Date: Tue, 20 Dec 2022 23:14:02 +0500 Subject: [PATCH] easier manager layers, frontend with nginx --- Dockerfile | 24 ++++++++++++++++++------ buildfiles/start_services.sh | 3 ++- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index a3d2775..cc10a78 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,16 +16,28 @@ RUN apt install git ca-certificates lsb-release apt-transport-https wget curl na RUN sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen \ && locale-gen -#Get the repos -RUN git clone https://git.shihaam.dev/shihaam/okiba-org-frontend \ - && git clone https://git.shihaam.dev/shihaam/okiba-org-backend \ + +#Install nginx, node and pnpm +RUN apt install nginx -y --no-install-recommends \ && curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash \ && curl -fsSL https://get.pnpm.io/install.sh | bash \ && source ~/.profile && source ~/.bashrc \ - && nvm install node \ + && nvm install node + +# Clone repos +RUN git clone https://git.shihaam.dev/shihaam/okiba-org-frontend \ + && git clone https://git.shihaam.dev/shihaam/okiba-org-backend + +# configure backend +RUN source ~/.profile && source ~/.bashrc \ && cd /root/okiba-org-backend ; pnpm build \ - && wget -O words.txt https://raw.githubusercontent.com/dwyl/english-words/master/words_alpha.txt \ - && cd /root/okiba-org-frontend ; pnpm install ; pnpm run build + && wget -O words.txt https://raw.githubusercontent.com/dwyl/english-words/master/words_alpha.txt + +# configure frontend +RUN source ~/.profile && source ~/.bashrc \ + && cd /root/okiba-org-frontend ; pnpm install ; pnpm build ; cd - \ + && mv /root/okiba-org-frontend/dist/* /var/www/html/ \ + && rm -rfv /root/okiba-org-frontend/ /var/www/html/index.nginx-debian.html # Copy Start Services COPY buildfiles/start_services.sh . diff --git a/buildfiles/start_services.sh b/buildfiles/start_services.sh index e077776..3cbb7fc 100644 --- a/buildfiles/start_services.sh +++ b/buildfiles/start_services.sh @@ -1,8 +1,9 @@ #!/bin/bash source $HOME/.profile; source $HOME/.bashrc + #Start frontend -cd /root/okiba-org-frontend; pnpm run dev --host & +/usr/sbin/nginx -g 'daemon off; master_process on;' & #Start backend cd /root/okiba-org-backend; pnpm start &