Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
corps-directory
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
fhurtado14
corps-directory
Commits
d3c210d3
Commit
d3c210d3
authored
6 months ago
by
Federico Hurtado
Browse files
Options
Downloads
Patches
Plain Diff
Able to get successful api call in the cluster.
parent
25c0f84a
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
README.md
+19
-7
19 additions, 7 deletions
README.md
docker-compose.yml
+2
-0
2 additions, 0 deletions
docker-compose.yml
frontend/.env
+1
-0
1 addition, 0 deletions
frontend/.env
frontend/src/components/Home.js
+7
-4
7 additions, 4 deletions
frontend/src/components/Home.js
with
29 additions
and
11 deletions
README.md
+
19
−
7
View file @
d3c210d3
#
Notes
#
Steps to run the full stack in local environment:
1.
run docker-compose up
2.
should be able to find servers using localhost 8080 and 3000
docker-compose down -> Will delete old containers
docker-compose build --no-cache -> Build new containers and copy updated files to containers
docker-compose up -> run new containers
# Steps to run in local environment:
note: If you only edit the frontend, you only need to rebuild the frontend. So to make the
process faster you can do "docker-compose build --no-cache frontend". The same applies to backend.
docker-compose down -> Will delete old container
docker-compose build --no-cache -> Build new container and copy updated files
docker-compose up -> run new container
# Steps to commit backend docker image to cluster
cd ./backend
docker build --platform=linux/amd64 -t container.cs.vt.edu/fhurtado14/corps-directory/backend:latest .
docker push container.cs.vt.edu/fhurtado14/corps-directory/backend:latest
Go to CS Launch and scale down backend deployment to 0, then scale back up to 1.
# Steps to commit frontend docker image to cluster
cd ./frontend
docker build --platform=linux/amd64 -t container.cs.vt.edu/fhurtado14/corps-directory/frontend:latest .
docker push container.cs.vt.edu/fhurtado14/corps-directory/frontend:latest
Go to CS Launch and scale down backend deployment to 0, then scale back up to 1.
This diff is collapsed.
Click to expand it.
docker-compose.yml
+
2
−
0
View file @
d3c210d3
...
...
@@ -19,6 +19,8 @@ services:
build
:
./frontend
ports
:
-
"
8080:80"
environment
:
-
REACT_APP_API_URL=http://localhost:3000/api
depends_on
:
-
backend
...
...
This diff is collapsed.
Click to expand it.
frontend/.env
0 → 100644
+
1
−
0
View file @
d3c210d3
REACT_APP_API_URL=http://localhost:3000/api
\ No newline at end of file
This diff is collapsed.
Click to expand it.
frontend/src/components/Home.js
+
7
−
4
View file @
d3c210d3
...
...
@@ -9,8 +9,11 @@ function Home() {
const
[
data
,
setData
]
=
useState
(
null
);
const
[
error
,
setError
]
=
useState
(
null
);
// url for API, need to use env variables before deploying
const
url
=
"
http://localhost:3000/api
"
;
// always use the REACT_APP_API_URL instead of http://localhost:3000
// bc our cluster has a different value for REACT_APP_API_URL
const
url
=
`
${
process
.
env
.
REACT_APP_API_URL
}
`
;
console
.
log
(
"
URL:
"
,
url
);
// async function to make the API call
const
fetchData
=
async
()
=>
{
...
...
@@ -31,12 +34,12 @@ function Home() {
<
div
>
<
h1
>
Home
Page
<
/h1
>
{
/* Display
"Data: [data]" or an empty space if data is null
*/
}
{
/* Display
data if it exists
*/
}
<
p
>
Data
:
{
data
?
<
span
>
{
JSON
.
stringify
(
data
)}
<
/span> : <span> </
span
>
}
<
/p
>
{
/*
D
isplay
"Error: [error]" or an empty space if no
error
*/
}
{
/*
d
isplay
error if there is an
error*/
}
<
p
>
Error
:
{
error
?
<
span
>
{
error
}
<
/span> : <span> </
span
>
}
<
/p
>
<
/div
>
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment