added pushing to AWS ECR

This commit is contained in:
Wenszel 2023-12-24 19:53:38 +01:00
parent 766614f5d2
commit 0b21489989
2 changed files with 21 additions and 29 deletions

View File

@ -1,12 +1,13 @@
version: 2.1
orbs:
aws-cli: circleci/aws-cli@4.1.2
aws-ecr: circleci/aws-ecr@9.0.1
jobs:
build_and_test:
docker:
- image: circleci/node:14
working_directory: ~/app
steps:
- checkout
- run:
@ -26,32 +27,23 @@ jobs:
name: Test Frontend
command: |
npm test
build_docker_image:
docker:
- image: circleci/node:14
working_directory: ~/app
steps:
- checkout
- run:
name: Build Docker Image
command: |
docker build -t $DOCKER_HUB_USERNAME/mern-ludo:latest .
- run:
name: Push Docker Image
command: |
echo "$DOCKER_HUB_PASSWORD" | docker login -u "$DOCKER_HUB_USERNAME" --password-stdin
docker push $DOCKER_HUB_USERNAME/mern-ludo:latest
workflows:
version: 2
build:
jobs:
- build_and_test
- build_docker_image:
filters:
branches:
only: main
test:
jobs:
- build_and_test
build_and_deploy:
jobs:
- aws-ecr/build_and_push_image:
auth:
- aws-cli/setup:
role_arn: arn:aws:iam::797929460436:role/openid
role_session_name: example-session
repo: mern-ludo
public_registry: true
tag: latest
filters:
branches:
only:
- main

View File

@ -13,7 +13,7 @@ function App() {
const [playerSocket, setPlayerSocket] = useState();
const [redirect, setRedirect] = useState();
useEffect(() => {
const socket = io('http://localhost:8080', { withCredentials: true });
const socket = io(`http://${window.location.hostname}:8080`, { withCredentials: true });
socket.on('player:data', data => {
data = JSON.parse(data);
setPlayerData(data);