From 030accaa06abaa0c1ccaff0c4b91d228d3dd6b1e Mon Sep 17 00:00:00 2001 From: Obasoro Olakunle Date: Fri, 4 Nov 2022 04:18:58 -0500 Subject: [PATCH 01/20] update --- api/Dockerfile | 17 +++++++++++++++++ frontend/Dockerfile | 25 +++++++++++++++++++++++++ frontend/new.txt | 0 frontend/src/components/App.js | 2 +- 4 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 api/Dockerfile create mode 100644 frontend/Dockerfile create mode 100644 frontend/new.txt diff --git a/api/Dockerfile b/api/Dockerfile new file mode 100644 index 000000000..0a3fae8e5 --- /dev/null +++ b/api/Dockerfile @@ -0,0 +1,17 @@ +# Import BaseImage +FROM python:3.10 + +RUN virtualenv env + +RUN source env/bin/activate + +# Install Depemdecies + +COPY requirements.txt . + +RUN pip install -r requirements.txt + +# Run the application: + +COPY manage.py . +CMD ["python", "manage.py"] diff --git a/frontend/Dockerfile b/frontend/Dockerfile new file mode 100644 index 000000000..61941d985 --- /dev/null +++ b/frontend/Dockerfile @@ -0,0 +1,25 @@ +# We don't want to start from scratch. +# That is why we tell node here to use the current node image as base. +FROM node:alpine + +# The /app directory should act as the main application directory +WORKDIR '/app' + +# Copy the app package and package-lock.json file +COPY package*.json . + +# Install node packages +RUN npm install + +# Copy or project directory (locally) in the current directory of our docker image (/app) +COPY . . + +# Build the app +RUN npm run build +# Start the app +CMD [ "npm", "start" ] + + + + + diff --git a/frontend/new.txt b/frontend/new.txt new file mode 100644 index 000000000..e69de29bb diff --git a/frontend/src/components/App.js b/frontend/src/components/App.js index d7d3bc5d9..c190622d9 100644 --- a/frontend/src/components/App.js +++ b/frontend/src/components/App.js @@ -11,7 +11,7 @@ class App extends Component {

HNGi9 DevOps Stage2 Task

- This task was submitted by Mayowa + This task was submitted by Obasoro Olakunle

); From f590e2162cb5abf79f27a6bfcb4750e73eea41c7 Mon Sep 17 00:00:00 2001 From: obasoro Date: Fri, 4 Nov 2022 22:38:52 -0500 Subject: [PATCH 02/20] update --- api/Dockerfile | 30 ++++++++++++++++++++++++++++ api/requirements.txt | 4 ++-- docker-compose.yml | 21 ++++++++++++++++++++ frontend/.dockerignore | 0 frontend/Dockerfile | 36 ++++++++++++++++++++++++++++++++++ frontend/src/components/App.js | 2 +- frontend/t.txt | 27 +++++++++++++++++++++++++ 7 files changed, 117 insertions(+), 3 deletions(-) create mode 100644 api/Dockerfile create mode 100644 docker-compose.yml create mode 100644 frontend/.dockerignore create mode 100644 frontend/Dockerfile create mode 100644 frontend/t.txt diff --git a/api/Dockerfile b/api/Dockerfile new file mode 100644 index 000000000..cacd1d976 --- /dev/null +++ b/api/Dockerfile @@ -0,0 +1,30 @@ +FROM python:latest + +# App Directory + +WORKDIR /usr/src/app + +ENV PYTHONDONTWRITEBYTECODE 1 +ENV PYTHONUNBUFFERED 1 + +# Create a virtual environment + +RUN python3 -m venv env + +RUN . env/bin/activate + +# Install Dependencies + +COPY /requirements.txt /usr/src/app/ + +RUN pip install --upgrade pip && pip install -r requirements.txt + +# copy project +COPY . . + +# Run the application + +EXPOSE 8000 + +CMD ["python", "manage.py", "runserver"] +#CMD [ "python", "manage.py", "runserver" "0.0.0.0:8000" ] \ No newline at end of file diff --git a/api/requirements.txt b/api/requirements.txt index 4ba2cf2e6..917f88a15 100644 --- a/api/requirements.txt +++ b/api/requirements.txt @@ -1,4 +1,4 @@ -Django==2.0.1 +Django djangorestframework==3.7.7 -psycopg2==2.9.5 +psycopg2-binary pytz==2017.3 diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 000000000..7e7da137b --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,21 @@ +version: '3' +services: + api: + image: 'obasoro/backend' + ports: + - "8000:8000" + volumes: + - ./api.:/api + restart: always + frontend: + image: 'obasoro/frontend' + ports: + - "3000:3000" + volumes: + - type: bind + + source : ./nginx/default.conf + + target: /etc/nginx/conf.d/default.conf + + restart: always \ No newline at end of file diff --git a/frontend/.dockerignore b/frontend/.dockerignore new file mode 100644 index 000000000..e69de29bb diff --git a/frontend/Dockerfile b/frontend/Dockerfile new file mode 100644 index 000000000..d94ffa6c8 --- /dev/null +++ b/frontend/Dockerfile @@ -0,0 +1,36 @@ +FROM node:alpine +ARG PORT + +# Create app directory +WORKDIR /usr/src/app + +ENV PATH /usr/src/app/node_modules/.bin:$PATH + +# Install app dependencies +# A wildcard is used to ensure both package.json AND package-lock.json are copied +# where available (npm@5+) +COPY package*.json /usr/src/app/ + +RUN npm cache clean --force + +#COPY node_modules/ ./ + +#RUN apt-get update && apt-get install netcat-openbsd -y + +RUN npm install + +# Bundle app source +COPY . . + +# Port + +EXPOSE 3000 + +RUN npm run build + +CMD [ "npm", "start" ] + +FROM nginx:stable-alpine + +COPY . /usr/share/nginx/html + diff --git a/frontend/src/components/App.js b/frontend/src/components/App.js index d7d3bc5d9..c4403f90d 100644 --- a/frontend/src/components/App.js +++ b/frontend/src/components/App.js @@ -11,7 +11,7 @@ class App extends Component {

HNGi9 DevOps Stage2 Task

- This task was submitted by Mayowa + This task was submitted by Olakunle Obasoro

); diff --git a/frontend/t.txt b/frontend/t.txt new file mode 100644 index 000000000..6f62db299 --- /dev/null +++ b/frontend/t.txt @@ -0,0 +1,27 @@ +# Import BaseImage +FROM node:alpine + +# Creating an application directory +RUN mkdir -p /app + +# The application working directory + +WORKDIR /app + +# Copy the app from local to the Image + +COPY package*.json . + +# Install node packages + +RUN npm install + +# Copy directory our docker image + +COPY . . + +# Build the app + +RUN npm run build + +CMD ["npm", "start"] \ No newline at end of file From b9aab0fc87f25a7c6419f73e8c7e2fc82a7af59a Mon Sep 17 00:00:00 2001 From: obasoro Date: Sat, 5 Nov 2022 02:40:17 -0500 Subject: [PATCH 03/20] update --- frontend/Dockerfile | 28 +--------------------------- 1 file changed, 1 insertion(+), 27 deletions(-) diff --git a/frontend/Dockerfile b/frontend/Dockerfile index 842f47f12..cf955e689 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -1,4 +1,4 @@ -<<<<<<< HEAD + FROM node:alpine ARG PORT @@ -34,30 +34,4 @@ CMD [ "npm", "start" ] FROM nginx:stable-alpine COPY . /usr/share/nginx/html -======= -# We don't want to start from scratch. -# That is why we tell node here to use the current node image as base. -FROM node:alpine - -# The /app directory should act as the main application directory -WORKDIR '/app' - -# Copy the app package and package-lock.json file -COPY package*.json . - -# Install node packages -RUN npm install - -# Copy or project directory (locally) in the current directory of our docker image (/app) -COPY . . - -# Build the app -RUN npm run build -# Start the app -CMD [ "npm", "start" ] - - - - ->>>>>>> 030accaa06abaa0c1ccaff0c4b91d228d3dd6b1e From b7ca64094129a26c8b30fa4277e1f450b0691021 Mon Sep 17 00:00:00 2001 From: obasoro Date: Sat, 5 Nov 2022 02:42:25 -0500 Subject: [PATCH 04/20] update --- api/Dockerfile | 22 +--------------------- 1 file changed, 1 insertion(+), 21 deletions(-) diff --git a/api/Dockerfile b/api/Dockerfile index 4592238dd..cacd1d976 100644 --- a/api/Dockerfile +++ b/api/Dockerfile @@ -1,4 +1,3 @@ -<<<<<<< HEAD FROM python:latest # App Directory @@ -28,23 +27,4 @@ COPY . . EXPOSE 8000 CMD ["python", "manage.py", "runserver"] -#CMD [ "python", "manage.py", "runserver" "0.0.0.0:8000" ] -======= -# Import BaseImage -FROM python:3.10 - -RUN virtualenv env - -RUN source env/bin/activate - -# Install Depemdecies - -COPY requirements.txt . - -RUN pip install -r requirements.txt - -# Run the application: - -COPY manage.py . -CMD ["python", "manage.py"] ->>>>>>> 030accaa06abaa0c1ccaff0c4b91d228d3dd6b1e +#CMD [ "python", "manage.py", "runserver" "0.0.0.0:8000" ] \ No newline at end of file From 000565d090229326bd2f27d5b0953d3aa34c52f7 Mon Sep 17 00:00:00 2001 From: obasoro Date: Sat, 5 Nov 2022 05:00:50 -0500 Subject: [PATCH 05/20] update --- api/Dockerfile | 4 ++-- frontend/Dockerfile | 16 +++++++++++++++- frontend/src/components/App.js | 4 ---- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/api/Dockerfile b/api/Dockerfile index cacd1d976..76fcd538f 100644 --- a/api/Dockerfile +++ b/api/Dockerfile @@ -26,5 +26,5 @@ COPY . . EXPOSE 8000 -CMD ["python", "manage.py", "runserver"] -#CMD [ "python", "manage.py", "runserver" "0.0.0.0:8000" ] \ No newline at end of file +#CMD ["python", "manage.py", "runserver"] +CMD [ "python", "manage.py", "runserver" "0.0.0.0:8000" ] \ No newline at end of file diff --git a/frontend/Dockerfile b/frontend/Dockerfile index cf955e689..5ddf043a7 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -31,7 +31,21 @@ RUN npm run build CMD [ "npm", "start" ] -FROM nginx:stable-alpine +FROM nginx:alpine +#!/bin/sh + +COPY . /etc/nginx/html + +## Remove default nginx index page +RUN rm -rf /usr/share/nginx/html/* + +# Copy from the stahg 1 COPY . /usr/share/nginx/html +EXPOSE 3000 80 + +ENTRYPOINT ["nginx", "-g", "daemon off;"] + + + diff --git a/frontend/src/components/App.js b/frontend/src/components/App.js index fd3e87821..c4403f90d 100644 --- a/frontend/src/components/App.js +++ b/frontend/src/components/App.js @@ -11,11 +11,7 @@ class App extends Component {

HNGi9 DevOps Stage2 Task

-<<<<<<< HEAD This task was submitted by Olakunle Obasoro -======= - This task was submitted by Obasoro Olakunle ->>>>>>> 030accaa06abaa0c1ccaff0c4b91d228d3dd6b1e

); From b69cce48f7d25f13f311ee5784795c77d7f789a5 Mon Sep 17 00:00:00 2001 From: obasoro Date: Sat, 5 Nov 2022 16:59:33 -0500 Subject: [PATCH 06/20] update --- api/Dockerfile | 29 +++++++++------------------- api/dev.Dockerfile | 46 +++++++++++++++++++++++++++++++++++++++++++++ dev.yml | 21 +++++++++++++++++++++ docker-compose.yml | 20 +++++--------------- frontend/Dockerfile | 21 +++++++++++---------- 5 files changed, 92 insertions(+), 45 deletions(-) create mode 100644 api/dev.Dockerfile create mode 100644 dev.yml diff --git a/api/Dockerfile b/api/Dockerfile index 76fcd538f..34d7ba0f4 100644 --- a/api/Dockerfile +++ b/api/Dockerfile @@ -1,30 +1,19 @@ -FROM python:latest - -# App Directory +# pull the official base image +FROM python:3.6-slim +# set work directory WORKDIR /usr/src/app ENV PYTHONDONTWRITEBYTECODE 1 ENV PYTHONUNBUFFERED 1 -# Create a virtual environment - -RUN python3 -m venv env - -RUN . env/bin/activate - -# Install Dependencies - -COPY /requirements.txt /usr/src/app/ - -RUN pip install --upgrade pip && pip install -r requirements.txt +# install dependencies +RUN pip install --upgrade pip +COPY ./requirements.txt /usr/src/app +RUN pip install -r requirements.txt # copy project -COPY . . - -# Run the application +COPY . /usr/src/app EXPOSE 8000 - -#CMD ["python", "manage.py", "runserver"] -CMD [ "python", "manage.py", "runserver" "0.0.0.0:8000" ] \ No newline at end of file +CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"] \ No newline at end of file diff --git a/api/dev.Dockerfile b/api/dev.Dockerfile new file mode 100644 index 000000000..01383d6e9 --- /dev/null +++ b/api/dev.Dockerfile @@ -0,0 +1,46 @@ +FROM python:3.10 + +# App Directory + +WORKDIR /usr/src/app + +ENV PYTHONDONTWRITEBYTECODE 1 +ENV PYTHONUNBUFFERED 1 + +# Create a virtual environment + +RUN python3 -m venv env + +RUN . env/bin/activate + +# Install Dependencies + +COPY /requirements.txt /usr/src/app/ + +RUN pip install --upgrade pip && pip install -r requirements.txt + +# copy project +COPY . . + +# Run the application + +# Use an official Python runtime as a parent image +# FROM python:3.8 + +# # Allows docker to cache installed dependencies between builds +# COPY requirements.txt requirements.txt +# RUN pip install --no-cache-dir -r requirements.txt + +# # Mounts the application code to the image +# COPY . code +# WORKDIR /code + +# EXPOSE 8000 + +# # runs the production server + +# EXPOSE 8000 + +# #CMD ["python", "manage.py", "runserver"] +ENTRYPOINT ["python", "manage.py"] +CMD ["runserver" "0.0.0.0:8000" ] \ No newline at end of file diff --git a/dev.yml b/dev.yml new file mode 100644 index 000000000..7e7da137b --- /dev/null +++ b/dev.yml @@ -0,0 +1,21 @@ +version: '3' +services: + api: + image: 'obasoro/backend' + ports: + - "8000:8000" + volumes: + - ./api.:/api + restart: always + frontend: + image: 'obasoro/frontend' + ports: + - "3000:3000" + volumes: + - type: bind + + source : ./nginx/default.conf + + target: /etc/nginx/conf.d/default.conf + + restart: always \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 7e7da137b..0d41f1f03 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,21 +1,11 @@ -version: '3' +version: '2' services: api: - image: 'obasoro/backend' + build: ./api ports: - "8000:8000" - volumes: - - ./api.:/api - restart: always - frontend: - image: 'obasoro/frontend' + + web: + build: ./frontend ports: - "3000:3000" - volumes: - - type: bind - - source : ./nginx/default.conf - - target: /etc/nginx/conf.d/default.conf - - restart: always \ No newline at end of file diff --git a/frontend/Dockerfile b/frontend/Dockerfile index 5ddf043a7..1e52a7d23 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -1,5 +1,5 @@ -FROM node:alpine +FROM node:alpine as builder ARG PORT # Create app directory @@ -31,21 +31,22 @@ RUN npm run build CMD [ "npm", "start" ] -FROM nginx:alpine +# FROM nginx:latest -#!/bin/sh +# #!/bin/sh -COPY . /etc/nginx/html +# COPY . /etc/nginx/html -## Remove default nginx index page -RUN rm -rf /usr/share/nginx/html/* +# ## Remove default nginx index page +# RUN rm -rf /usr/share/nginx/html/* -# Copy from the stahg 1 -COPY . /usr/share/nginx/html +# # Copy from the stahg 1 +# COPY --from=builder /usr/src/app/build /usr/share/nginx/html -EXPOSE 3000 80 +# EXPOSE 3000 80 -ENTRYPOINT ["nginx", "-g", "daemon off;"] + +# ENTRYPOINT ["nginx", "-g", "daemon off;"] From 7e3a6beb43dbd7a84b73b15eb70bfb3ab8e14e10 Mon Sep 17 00:00:00 2001 From: obasoro Date: Sat, 5 Nov 2022 17:09:49 -0500 Subject: [PATCH 07/20] update --- api/api/settings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/api/settings.py b/api/api/settings.py index 22bc4381f..12666faaf 100644 --- a/api/api/settings.py +++ b/api/api/settings.py @@ -25,7 +25,7 @@ # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True -ALLOWED_HOSTS = [] +ALLOWED_HOSTS = ["*"] # Application definition From e44fe9256541865cb215c204b3c232bfdafcf417 Mon Sep 17 00:00:00 2001 From: Obasoro Olakunle Date: Sun, 6 Nov 2022 09:59:09 -0600 Subject: [PATCH 08/20] update --- api/Dockerfile | 24 +++++++++++++----------- api/requirements.txt | 2 +- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/api/Dockerfile b/api/Dockerfile index 0a3fae8e5..34d7ba0f4 100644 --- a/api/Dockerfile +++ b/api/Dockerfile @@ -1,17 +1,19 @@ -# Import BaseImage -FROM python:3.10 +# pull the official base image +FROM python:3.6-slim -RUN virtualenv env +# set work directory +WORKDIR /usr/src/app -RUN source env/bin/activate - -# Install Depemdecies - -COPY requirements.txt . +ENV PYTHONDONTWRITEBYTECODE 1 +ENV PYTHONUNBUFFERED 1 +# install dependencies +RUN pip install --upgrade pip +COPY ./requirements.txt /usr/src/app RUN pip install -r requirements.txt -# Run the application: +# copy project +COPY . /usr/src/app -COPY manage.py . -CMD ["python", "manage.py"] +EXPOSE 8000 +CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"] \ No newline at end of file diff --git a/api/requirements.txt b/api/requirements.txt index 4ba2cf2e6..284f30f99 100644 --- a/api/requirements.txt +++ b/api/requirements.txt @@ -1,4 +1,4 @@ Django==2.0.1 djangorestframework==3.7.7 -psycopg2==2.9.5 +psycopg2-binary pytz==2017.3 From 1ca695cc396999d77d1e4c6993cff5a95a89bb3c Mon Sep 17 00:00:00 2001 From: Obasoro Olakunle Date: Sun, 6 Nov 2022 11:54:15 -0600 Subject: [PATCH 09/20] update --- nginx.conf | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 nginx.conf diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 000000000..e69de29bb From 538a40e1c41d2d22921f02181ac92aff63a9ffa5 Mon Sep 17 00:00:00 2001 From: Obasoro Olakunle Date: Sun, 6 Nov 2022 11:59:20 -0600 Subject: [PATCH 10/20] updated docker-compose --- docker-compose.yml | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 0d41f1f03..5d8020b60 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,11 +1,22 @@ -version: '2' + +version: "3" + services: - api: - build: ./api - ports: - - "8000:8000" + frontend: + image: obasoro/frontend-react:latest + container_name: frontendpage + ports: + - 3000:3000 + depends_on: + - backend - web: - build: ./frontend - ports: - - "3000:3000" + backend: + image: obasoro/backend-django:latest + container_name: backend + command: python manage.py runserver 0.0.0.0:8000 + ports: + - "8000:8000" +networks: + default: + name: + external: \ No newline at end of file From c7f3b2c436d008b418b62586d69fdfbccf816195 Mon Sep 17 00:00:00 2001 From: Obasoro Olakunle Date: Sun, 6 Nov 2022 12:12:19 -0600 Subject: [PATCH 11/20] nginx --- frontend/nginx.conf | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 frontend/nginx.conf diff --git a/frontend/nginx.conf b/frontend/nginx.conf new file mode 100644 index 000000000..e69de29bb From 1d162af8d56b6cacb6c5cf2bbe856463eb21d903 Mon Sep 17 00:00:00 2001 From: Obasoro Date: Sun, 6 Nov 2022 19:29:45 -0600 Subject: [PATCH 12/20] Create Process and Method.md --- Process and Method.md | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 Process and Method.md diff --git a/Process and Method.md b/Process and Method.md new file mode 100644 index 000000000..d31c439b8 --- /dev/null +++ b/Process and Method.md @@ -0,0 +1,8 @@ +Here is your stage 2 task: +Your stage 2 task is centred around containerisation :package:. +:bulb:Task Details: +You are provided a simple application with the frontend in JavaScript(React) and backend in Python(Django). This is the link to the Repository. Follow instructions on how to deploy the application locally on your server. It should look like this. NB: It should have your slack display name +You are then required to build docker images of the frontend and backend using a Dockerfile for each and push them to a docker repository eg docker hub, ecr etc. +You are then required to create a docker-compose file that can spin up images into containers and are connected with one another. A simple docker-compose up should be able to start the application. If successful the frontend application should run on port 3000 of your server IP. +You are then required to use reverse proxy with NGINX to point port 3000 to the IP of your server. +Push your code to GitHub, it should be in the following format. From 7dfc816c853f776b10a51c32cc2b181201ee7e1b Mon Sep 17 00:00:00 2001 From: Obasoro Date: Sun, 6 Nov 2022 19:32:02 -0600 Subject: [PATCH 13/20] Update Process and Method.md --- Process and Method.md | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/Process and Method.md b/Process and Method.md index d31c439b8..aaea72e1b 100644 --- a/Process and Method.md +++ b/Process and Method.md @@ -1,8 +1,11 @@ Here is your stage 2 task: -Your stage 2 task is centred around containerisation :package:. -:bulb:Task Details: -You are provided a simple application with the frontend in JavaScript(React) and backend in Python(Django). This is the link to the Repository. Follow instructions on how to deploy the application locally on your server. It should look like this. NB: It should have your slack display name -You are then required to build docker images of the frontend and backend using a Dockerfile for each and push them to a docker repository eg docker hub, ecr etc. -You are then required to create a docker-compose file that can spin up images into containers and are connected with one another. A simple docker-compose up should be able to start the application. If successful the frontend application should run on port 3000 of your server IP. -You are then required to use reverse proxy with NGINX to point port 3000 to the IP of your server. + +### containerisation :package:. + +You are provided a simple application with the frontend in JavaScript(React) and backend in Python(Django). +Follow instructions on how to deploy the application locally on your server. It should look like this. NB: It should have your slack display name + +1. You are then required to build docker images of the frontend and backend using a Dockerfile for each and push them to a docker repository eg docker hub, ecr etc. +2. You are then required to create a docker-compose file that can spin up images into containers and are connected with one another. A simple docker-compose up should be able to start the application. If successful the frontend application should run on port 3000 of your server IP. +3. You are then required to use reverse proxy with NGINX to point port 3000 to the IP of your server. Push your code to GitHub, it should be in the following format. From 582cf63e677ead7522378b03523d2ae4ab59eed8 Mon Sep 17 00:00:00 2001 From: Obasoro Date: Sun, 6 Nov 2022 20:02:29 -0600 Subject: [PATCH 14/20] Update Process and Method.md --- Process and Method.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Process and Method.md b/Process and Method.md index aaea72e1b..7c59cd159 100644 --- a/Process and Method.md +++ b/Process and Method.md @@ -9,3 +9,21 @@ Follow instructions on how to deploy the application locally on your server. It 2. You are then required to create a docker-compose file that can spin up images into containers and are connected with one another. A simple docker-compose up should be able to start the application. If successful the frontend application should run on port 3000 of your server IP. 3. You are then required to use reverse proxy with NGINX to point port 3000 to the IP of your server. Push your code to GitHub, it should be in the following format. + + +### Fork the repo and clone into your system/server + +### customize the the name + +1. Open App.js with the Frontend folder and change the name to user slack name + +2. You can test the frontend by running this commands + +``` +`$ cd frontend` + +`$ npm i` + +`$ npm start` + +``` From ffacdd950db1225e92c942628e7f3e904c7c2c78 Mon Sep 17 00:00:00 2001 From: Obasoro Date: Sun, 6 Nov 2022 20:06:43 -0600 Subject: [PATCH 15/20] Update Process and Method.md --- Process and Method.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Process and Method.md b/Process and Method.md index 7c59cd159..d4a7af4ed 100644 --- a/Process and Method.md +++ b/Process and Method.md @@ -27,3 +27,16 @@ Push your code to GitHub, it should be in the following format. `$ npm start` ``` + +``` +To test the backend also... Navigate into the folder api + +Create a virtual environment + +`$ python3 -m venv env` + +`$ source env/bin/activate` + +`$ pip install -r requirement` + +`$ python manage.py runserver` From 839dab896abe5e4dcdd5448707b342a968b23c92 Mon Sep 17 00:00:00 2001 From: Obasoro Date: Sun, 6 Nov 2022 20:13:37 -0600 Subject: [PATCH 16/20] Update Process and Method.md --- Process and Method.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Process and Method.md b/Process and Method.md index d4a7af4ed..27f2b1c3e 100644 --- a/Process and Method.md +++ b/Process and Method.md @@ -40,3 +40,10 @@ Create a virtual environment `$ pip install -r requirement` `$ python manage.py runserver` + +## Create a Dockerfile + +``` +You either do it on the CLI or open a Vscode. I will be using Vscode because of ease and accessibility to CLI also + + From 5325df95abe7edea5ab3fe3e4233edca9d264e0a Mon Sep 17 00:00:00 2001 From: Obasoro Date: Sun, 6 Nov 2022 20:22:42 -0600 Subject: [PATCH 17/20] Update Process and Method.md --- Process and Method.md | 1 + 1 file changed, 1 insertion(+) diff --git a/Process and Method.md b/Process and Method.md index 27f2b1c3e..9eb906b93 100644 --- a/Process and Method.md +++ b/Process and Method.md @@ -27,6 +27,7 @@ Push your code to GitHub, it should be in the following format. `$ npm start` ``` +![image](https://user-images.githubusercontent.com/29310552/200212777-d5846165-7b2d-49a5-af7c-a841b678c303.png) ``` To test the backend also... Navigate into the folder api From afbaff1e23ebc961d72f3591cdcdec0940c6044e Mon Sep 17 00:00:00 2001 From: Obasoro Date: Sun, 6 Nov 2022 21:52:38 -0600 Subject: [PATCH 18/20] Update Process and Method.md --- Process and Method.md | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/Process and Method.md b/Process and Method.md index 9eb906b93..5fdc2c890 100644 --- a/Process and Method.md +++ b/Process and Method.md @@ -47,4 +47,34 @@ Create a virtual environment ``` You either do it on the CLI or open a Vscode. I will be using Vscode because of ease and accessibility to CLI also +Building the image + +`$ docker build -t obasoro/frontend .` + +`$ docker run -it -p port:port image name` + +![image](https://user-images.githubusercontent.com/29310552/200222502-d169ad9b-e9b3-4782-83a1-19bc299ce0cb.png) + + +Docker-compose.yml file +![image](https://user-images.githubusercontent.com/29310552/200222825-47a273c8-b5a5-413d-959f-ae29de69f7c2.png) + + + + + + +![image](https://user-images.githubusercontent.com/29310552/200222152-8134c863-f59c-48a4-a6bb-1b0e094a97ea.png) + +![image](https://user-images.githubusercontent.com/29310552/200222022-eb79812c-92be-4d5e-9da5-f3c6b7ffd4ac.png) + +`$ docker-compsose up` + +The container image would be spinned up. + +![image](https://user-images.githubusercontent.com/29310552/200222232-8d229414-ee23-4c1a-a65b-d2ca9306441e.png) + +[DigitalOcean](https://www.digitalocean.com/community/tutorials/how-to-install-nginx-on-ubuntu-20-04) + + From 4f5ef48eb1a14413047296c5cee25cbe1c41d666 Mon Sep 17 00:00:00 2001 From: Obasoro Olakunle Date: Mon, 7 Nov 2022 13:19:16 -0600 Subject: [PATCH 19/20] update --- api/Dockerfile | 20 ++++++++++++++++++++ api/api/settings.py | 2 +- api/requirements.txt | 4 ++-- frontend/Dockerfile | 8 ++++++++ frontend/src/components/App.js | 2 +- 5 files changed, 32 insertions(+), 4 deletions(-) create mode 100644 api/Dockerfile create mode 100644 frontend/Dockerfile diff --git a/api/Dockerfile b/api/Dockerfile new file mode 100644 index 000000000..5ec8cb821 --- /dev/null +++ b/api/Dockerfile @@ -0,0 +1,20 @@ +# pull the official base image +FROM python:3.6-slim + +# set work directory +WORKDIR /usr/src/app + +# set environment variables +ENV PYTHONDONTWRITEBYTECODE 1 +ENV PYTHONUNBUFFERED 1 + +# install dependencies +RUN pip install --upgrade pip +COPY ./requirements.txt /usr/src/app +RUN pip install -r requirements.txt + +# copy project +COPY . /usr/src/app + +EXPOSE 8008 +CMD ["python", "manage.py", "runserver", "0.0.0.0:8008"] \ No newline at end of file diff --git a/api/api/settings.py b/api/api/settings.py index 22bc4381f..12666faaf 100644 --- a/api/api/settings.py +++ b/api/api/settings.py @@ -25,7 +25,7 @@ # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True -ALLOWED_HOSTS = [] +ALLOWED_HOSTS = ["*"] # Application definition diff --git a/api/requirements.txt b/api/requirements.txt index 4ba2cf2e6..2a4c299e1 100644 --- a/api/requirements.txt +++ b/api/requirements.txt @@ -1,4 +1,4 @@ Django==2.0.1 djangorestframework==3.7.7 -psycopg2==2.9.5 -pytz==2017.3 +psycopg2-binary +pytz==2017.3 \ No newline at end of file diff --git a/frontend/Dockerfile b/frontend/Dockerfile new file mode 100644 index 000000000..0d50b1c4f --- /dev/null +++ b/frontend/Dockerfile @@ -0,0 +1,8 @@ +FROM node:19-alpine3.15 +WORKDIR /frontend +COPY package*.json ./ +RUN npm install +COPY . . +RUN npm run build +EXPOSE 3000 +CMD ["npx", "serve", "build"] \ No newline at end of file diff --git a/frontend/src/components/App.js b/frontend/src/components/App.js index d7d3bc5d9..c190622d9 100644 --- a/frontend/src/components/App.js +++ b/frontend/src/components/App.js @@ -11,7 +11,7 @@ class App extends Component {

HNGi9 DevOps Stage2 Task

- This task was submitted by Mayowa + This task was submitted by Obasoro Olakunle

); From 0dcf25543ffd312850c504ad1c1b7d411d347199 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Mon, 7 Nov 2022 21:35:15 +0000 Subject: [PATCH 20/20] update --- api/Dockerfile | 20 +++++++++++++++ api/dev.Dockerfile | 46 ---------------------------------- api/requirements.txt | 6 ++--- docker-compose.yml | 8 +++--- frontend/src/components/App.js | 2 +- 5 files changed, 27 insertions(+), 55 deletions(-) delete mode 100644 api/dev.Dockerfile diff --git a/api/Dockerfile b/api/Dockerfile index e69de29bb..8b5b16794 100644 --- a/api/Dockerfile +++ b/api/Dockerfile @@ -0,0 +1,20 @@ +# pull the official base image +FROM python:3.6-slim + +# set work directory +WORKDIR /usr/src/app + +# set environment variables +ENV PYTHONDONTWRITEBYTECODE 1 +ENV PYTHONUNBUFFERED 1 + +# install dependencies +RUN pip install --upgrade pip +COPY ./requirements.txt /usr/src/app +RUN pip install -r requirements.txt + +# copy project +COPY . /usr/src/app + +EXPOSE 8000 +CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"] diff --git a/api/dev.Dockerfile b/api/dev.Dockerfile deleted file mode 100644 index 01383d6e9..000000000 --- a/api/dev.Dockerfile +++ /dev/null @@ -1,46 +0,0 @@ -FROM python:3.10 - -# App Directory - -WORKDIR /usr/src/app - -ENV PYTHONDONTWRITEBYTECODE 1 -ENV PYTHONUNBUFFERED 1 - -# Create a virtual environment - -RUN python3 -m venv env - -RUN . env/bin/activate - -# Install Dependencies - -COPY /requirements.txt /usr/src/app/ - -RUN pip install --upgrade pip && pip install -r requirements.txt - -# copy project -COPY . . - -# Run the application - -# Use an official Python runtime as a parent image -# FROM python:3.8 - -# # Allows docker to cache installed dependencies between builds -# COPY requirements.txt requirements.txt -# RUN pip install --no-cache-dir -r requirements.txt - -# # Mounts the application code to the image -# COPY . code -# WORKDIR /code - -# EXPOSE 8000 - -# # runs the production server - -# EXPOSE 8000 - -# #CMD ["python", "manage.py", "runserver"] -ENTRYPOINT ["python", "manage.py"] -CMD ["runserver" "0.0.0.0:8000" ] \ No newline at end of file diff --git a/api/requirements.txt b/api/requirements.txt index 93afb56bd..284f30f99 100644 --- a/api/requirements.txt +++ b/api/requirements.txt @@ -1,4 +1,4 @@ -Django +Django==2.0.1 djangorestframework==3.7.7 -psycopg2==2.9.5 -pytz==2017.3 \ No newline at end of file +psycopg2-binary +pytz==2017.3 diff --git a/docker-compose.yml b/docker-compose.yml index 5d8020b60..5b0c0b837 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,20 +3,18 @@ version: "3" services: frontend: - image: obasoro/frontend-react:latest - container_name: frontendpage + image: obasoro/frontend-react-new:latest ports: - 3000:3000 depends_on: - backend backend: - image: obasoro/backend-django:latest - container_name: backend + image: obasoro/api:latest command: python manage.py runserver 0.0.0.0:8000 ports: - "8000:8000" networks: default: name: - external: \ No newline at end of file + external: diff --git a/frontend/src/components/App.js b/frontend/src/components/App.js index d7d3bc5d9..c190622d9 100644 --- a/frontend/src/components/App.js +++ b/frontend/src/components/App.js @@ -11,7 +11,7 @@ class App extends Component {

HNGi9 DevOps Stage2 Task

- This task was submitted by Mayowa + This task was submitted by Obasoro Olakunle

);