Skip to content

Commit

Permalink
Merge pull request #9 from OSobky/release/v1.0
Browse files Browse the repository at this point in the history
Release/v1.0
  • Loading branch information
aahmedashraaf authored Dec 3, 2018
2 parents 717ed0f + 5fae0a3 commit 3e86268
Show file tree
Hide file tree
Showing 5 changed files with 360 additions and 99 deletions.
1 change: 0 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ RUN go get -u github.com/kardianos/govendor
WORKDIR /go/src/app
COPY . .

EXPOSE 3000

# Install dependencies
RUN govendor sync
Expand Down
49 changes: 49 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,52 @@
Web Application that gets students comments on Facebook posts/photos which related to their courses
Ahmed Ashraf 37-6150
Omar Ashraf 37-6244

Get the vendor tool to declare and isolate the dependencies by writing this command "go get -u github.com/kardianos/govendor" then we use it at the docker file and if you want to use it without docker you can write these two commands "govender sync" and "govendor build".

We have several enviroment variables which are:
DATABASE_HOST: which is the host database that the app uses
DATABASE_USER: the username of the database
DATABASE_PASSWORD: the password of the database
DATABASE_NAME: the database name
ACCESS_TOKEN: a valid user access token
POSTGRES_PASSWORD: the database password
POSTGRES_USER: the databse username
POSTGRES_DB: the database name

To Run the Web App using docker run command :

1.Run the data base with it config (POSTGRES_USER,POSTGRES_PASSWORD,POSTGRES_DB) and give it name "pg_container"
for Example : docker run --name pg_container -e POSTGRES_USER=user -e POSTGRES_PASSWORD=password -e POSTGRES_DB=name -p 5432:5432 -d healthcheck/postgres:alpine
2.Build the App Dockerfile and give it tag guc
for Example : docker build -t guc .

3.Run the App container with passing the enviroment variables ( DATABASE_HOST DATABASE_USER DATABASE_PASSWORD DATABASE_NAME ACCESS_TOKEN) and set the ports to 3000:8080
for example :
docker run -e DATABASE_HOST=db -e DATABASE_USER=user -e DATABASE_PASSWORD=password -e DATABASE_NAME=name -e ACCESS_TOKEN=(a valid access token) --link=pg_container:db -p 3000:8080 guc

--the flags used in the docker run command is : 1.-e to set enviroment variables
2.-p to set the port of the container
3.-d Run container in background and print container ID
4.-t to give your container a tag name
5.--link to link the host of pg_container to DATABASE_HOST


To Run the Web App using docker-compose command :

1.Set the enviroment variables in the docker-compose.yaml file
for example for:
DATABASE_HOST: db
DATABASE_USER: user
DATABASE_PASSWORD: password
DATABASE_NAME: name
ACCESS_TOKEN: (a valid access token)
POSTGRES_PASSWORD: password
POSTGRES_USER: user
POSTGRES_DB: name
2.Run docker-compose up --build -d , then your app is and built and on
3.to stop the app use docker-compose down and docker-compose stop

--the flags used in the docker compose command is :
1.--build to build the container again
2.-d Run container in background and print container ID
14 changes: 7 additions & 7 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ services:
build: .
environment:
DATABASE_HOST: db
DATABASE_USER: root
DATABASE_PASSWORD: secret
DATABASE_NAME: GUC_Comments
ACCESS_TOKEN: "EAAFDrTDhvyMBAEt2GZAyMW9xPsLNnhz8ZAXh8ehZBTU6b5ug8ciAZBSulKOEDDbS2GtrokaGIKyOZAagiNCvRrZCl1nXaR6xtZBmGoXeSOISqihq7sDM3TZBj6hC2ZCEpwP3In3jo2ZAj5xlPNgMbYTgNWProADC3C2XNWe1FH7egJKwZDZD"
DATABASE_USER: user
DATABASE_PASSWORD: password
DATABASE_NAME: name
ACCESS_TOKEN: (a valid access token)
ports:
- 3000:8080
depends_on:
Expand All @@ -18,6 +18,6 @@ services:
image: healthcheck/postgres:alpine

environment:
POSTGRES_PASSWORD: secret
POSTGRES_USER: root
POSTGRES_DB: GUC_Comments
POSTGRES_PASSWORD: password
POSTGRES_USER: user
POSTGRES_DB: name
53 changes: 53 additions & 0 deletions guc_comments.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<html>
<head>
<style>
table {
font-family: arial, sans-serif;
border-collapse: collapse;
width: 100%;
}

td, th {
border: 1px solid #dddddd;
text-align: left;
padding: 8px;
}

tr:nth-child(even) {
background-color: #dddddd;
}
</style>
</head>
<body>

<h1> GUC Comments</h1>

<h2>{{.Course}} </h2>


<select onchange="rout(this.value)">
<option> </option>
<option value="http://localhost:3000/MICRO">CSEN 702 Microprocessors </option>
<option value="http://localhost:3000/ANALYSIS">CSEN 703 Analysis and Design of Algorithms </option>
<option value="http://localhost:3000/ADVANCED">CSEN 704 Advanced computer lab </option>
</select>

<script>
function rout(src){
window.location.href=src;
}
</script>
<table>
<tr>
<th>Comments</th>
</tr>
{{range .Guccommentss}}
<tr>
<td>
{{.Comments}}
</td>
</tr>
{{end}}
</table>
</body>
</html>
Loading

0 comments on commit 3e86268

Please sign in to comment.