Skip to content

Commit

Permalink
Merge pull request #14 from haidousm/fix/websocket-disconnect
Browse files Browse the repository at this point in the history
Fix - Websocket Disconnect because of leftover namespace
  • Loading branch information
haidousm committed Feb 13, 2022
2 parents d81eac8 + b0a6f6f commit 333741a
Show file tree
Hide file tree
Showing 7 changed files with 141 additions and 126 deletions.
80 changes: 47 additions & 33 deletions .github/workflows/dev-docker-images.yml
Original file line number Diff line number Diff line change
@@ -1,39 +1,53 @@
name: Build & Deploy Dev. Docker Images

on:
push:
branches:
- 'main'
workflow_dispatch:
push:
branches:
- "main"
workflow_dispatch:

jobs:
build-api:
name: Build API's Image
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: docker login
env:
DOCKER_USER: ${{secrets.DOCKER_USER}}
DOCKER_PASSWORD: ${{secrets.DOCKER_PASSWORD}}
run: |
docker login -u $DOCKER_USER -p $DOCKER_PASSWORD
- name: Build the Docker Image
run: |
docker build api --tag haidousm/traefiker-api:SNAPSHOT
- name: Push the Docker Image to DockerHub
run: |
docker push haidousm/traefiker-api:SNAPSHOT
build-client:
name: Build Client's Image
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: docker login
env:
DOCKER_USER: ${{secrets.DOCKER_USER}}
DOCKER_PASSWORD: ${{secrets.DOCKER_PASSWORD}}
run: |
docker login -u $DOCKER_USER -p $DOCKER_PASSWORD
- name: Build the Docker Image
run: |
docker build client --tag haidousm/traefiker-web:SNAPSHOT
- name: Push the Docker Image to DockerHub
run: |
docker push haidousm/traefiker-web:SNAPSHOT
docker:
name: Build Docker Image
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: docker login
env:
DOCKER_USER: ${{secrets.DOCKER_USER}}
DOCKER_PASSWORD: ${{secrets.DOCKER_PASSWORD}}
run: |
docker login -u $DOCKER_USER -p $DOCKER_PASSWORD
- name: Build the Docker Image
run: |
docker build api --tag haidousm/traefiker-api:SNAPSHOT
docker build client --tag haidousm/traefiker-web:SNAPSHOT
- name: Push the Docker Image to DockerHub
run: |
docker push haidousm/traefiker-api:SNAPSHOT
docker push haidousm/traefiker-web:SNAPSHOT
# deploy:
# name: Deploy Dev. Docker Image
# runs-on: ubuntu-latest
# needs: [ docker ]
# steps:
# - name: Call Webhook
# uses: joelwmale/webhook-action@master
# env:
# WEBHOOK_URL: ${{ secrets.DEPLOY_WEBHOOK_URL }}
# deploy:
# name: Deploy Dev. Docker Image
# runs-on: ubuntu-latest
# needs: [ docker ]
# steps:
# - name: Call Webhook
# uses: joelwmale/webhook-action@master
# env:
# WEBHOOK_URL: ${{ secrets.DEPLOY_WEBHOOK_URL }}
84 changes: 49 additions & 35 deletions .github/workflows/prod-docker-images.yml
Original file line number Diff line number Diff line change
@@ -1,41 +1,55 @@
name: Build & Deploy Prod. Docker Images

on:
push:
branches:
- 'releases/**'
workflow_dispatch:
push:
branches:
- "releases/**"
workflow_dispatch:

jobs:
build-api:
name: Build API's Image
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: docker login
env:
DOCKER_USER: ${{secrets.DOCKER_USER}}
DOCKER_PASSWORD: ${{secrets.DOCKER_PASSWORD}}
run: |
docker login -u $DOCKER_USER -p $DOCKER_PASSWORD
- name: Build the Docker Image
run: |
docker build api --file Dockerfile --tag haidousm/traefiker-api:latest --tag haidousm/traefiker-api:${GITHUB_REF##*/}
- name: Push the Docker Image to DockerHub
run: |
docker push haidousm/traefiker-api:${GITHUB_REF##*/}
docker push haidousm/traefiker-api:latest
build-client:
name: Build Client's Image
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: docker login
env:
DOCKER_USER: ${{secrets.DOCKER_USER}}
DOCKER_PASSWORD: ${{secrets.DOCKER_PASSWORD}}
run: |
docker login -u $DOCKER_USER -p $DOCKER_PASSWORD
- name: Build the Docker Image
run: |
docker build client --file Dockerfile --tag haidousm/traefiker-web:latest --tag haidousm/traefiker-web:${GITHUB_REF##*/}
- name: Push the Docker Image to DockerHub
run: |
docker push haidousm/traefiker-web:${GITHUB_REF##*/}
docker push haidousm/traefiker-web:latest
docker:
name: Build Docker Image
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: docker login
env:
DOCKER_USER: ${{secrets.DOCKER_USER}}
DOCKER_PASSWORD: ${{secrets.DOCKER_PASSWORD}}
run: |
docker login -u $DOCKER_USER -p $DOCKER_PASSWORD
- name: Build the Docker Image
run: |
docker build api --file Dockerfile --tag haidousm/traefiker-api:latest --tag haidousm/traefiker-api:${GITHUB_REF##*/}
docker build client --file Dockerfile --tag haidousm/traefiker-web:latest --tag haidousm/traefiker-web:${GITHUB_REF##*/}
- name: Push the Docker Image to DockerHub
run: |
docker push haidousm/traefiker-api:${GITHUB_REF##*/}
docker push haidousm/traefiker-api:latest
docker push haidousm/traefiker-web:${GITHUB_REF##*/}
docker push haidousm/traefiker-web:latest
# deploy:
# name: Deploy Prod. Docker Image
# runs-on: ubuntu-latest
# needs: [ docker ]
# steps:
# - name: Call Webhook
# uses: joelwmale/webhook-action@master
# env:
# WEBHOOK_URL: ${{ secrets.DEPLOY_WEBHOOK_URL }}
# deploy:
# name: Deploy Prod. Docker Image
# runs-on: ubuntu-latest
# needs: [ docker ]
# steps:
# - name: Call Webhook
# uses: joelwmale/webhook-action@master
# env:
# WEBHOOK_URL: ${{ secrets.DEPLOY_WEBHOOK_URL }}
2 changes: 1 addition & 1 deletion api/src/models/Service.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ ServiceSchema.pre("save", function (next) {
const status = this.status;
if (io.sockets) {
io.sockets.emit("status", {
serviceId: this._id,
serviceName: this.name,
status,
});
}
Expand Down
50 changes: 12 additions & 38 deletions client/src/components/dashboard/table/DashboardTableBody.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable react-hooks/exhaustive-deps */
import { useEffect, useState } from "react";
import { DragDropContext, Droppable } from "react-beautiful-dnd";
import { useRecoilState } from "recoil";
Expand Down Expand Up @@ -61,20 +62,14 @@ function DashboardTableBody({ columns }: Props) {
useEffect(() => {
(async () => {
const services = await getServices();
setServices(
services.sort((a: Service, b: Service) => a.order - b.order)
);
await sortAndSetServices(services);
})();
}, [setServices]);
}, []);

useEffect(() => {
setIsEditingService(serviceUnderEditing !== undefined);
}, [serviceUnderEditing]);

useEffect(() => {
updateServiceOrdering(services);
}, [services]);

const sortAndSetServices = async (services: Service[]) => {
setServices(
services.sort((a: Service, b: Service) => a.order - b.order)
Expand All @@ -90,7 +85,8 @@ function DashboardTableBody({ columns }: Props) {
result.source.index,
result.destination.index
);
sortAndSetServices(reorderedServices);
setServices(reorderedServices);
updateServiceOrdering(reorderedServices);
};

const saveClicked = async (service: Service) => {
Expand All @@ -100,7 +96,7 @@ function DashboardTableBody({ columns }: Props) {
if (index !== -1) {
const updatedServices = [...services];
updatedServices[index] = service;
sortAndSetServices(updatedServices);
await sortAndSetServices(updatedServices);
await updateService(service);
} else {
setLoadingFlags({
Expand All @@ -109,13 +105,13 @@ function DashboardTableBody({ columns }: Props) {
});
service.order = services.length;
await createService(service);
const updatedServices = await getServices();
await sortAndSetServices(updatedServices);
setLoadingFlags({
...loadingFlags,
creatingService: false,
});
}
const updatedServices = await getServices();
sortAndSetServices(updatedServices);
setLoadingFlags({
...loadingFlags,
creatingService: false,
});
};
const cancelClicked = () => {
setServiceUnderEditing(undefined);
Expand All @@ -131,8 +127,6 @@ function DashboardTableBody({ columns }: Props) {
prevServices.filter((s) => s.name !== service.name)
);
await deleteService(service);
const updatedServices = await getServices();
sortAndSetServices(updatedServices);
};

const redirectsClicked = (service: Service) => {
Expand All @@ -143,31 +137,11 @@ function DashboardTableBody({ columns }: Props) {
};

const startServiceClicked = async (service: Service) => {
setServices(
services.map((s) => {
if (s.name === service.name) {
return { ...s, status: "running" };
}
return s;
})
);
await startService(service);
const updatedServices = await getServices();
sortAndSetServices(updatedServices);
};

const stopServiceClicked = async (service: Service) => {
setServices(
services.map((s) => {
if (s.name === service.name) {
return { ...s, status: "stopped" };
}
return s;
})
);
await stopService(service);
const updatedServices = await getServices();
sortAndSetServices(updatedServices);
};

return (
Expand Down
18 changes: 9 additions & 9 deletions client/src/components/dashboard/table/DashboardTableRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ function DashboardTableRow({
>
<td
className={
"whitespace-nowrap px-2 py-1 text-center lg:px-6 lg:py-4 " +
"w-2/12 whitespace-nowrap px-2 py-1 text-center lg:px-6 lg:py-4 " +
getStatusColor()
}
style={{
Expand All @@ -111,7 +111,7 @@ function DashboardTableRow({
{service.tag}
</span>
</td>
<td className="hidden whitespace-nowrap px-2 py-1 text-center sm:table-cell lg:px-6 lg:py-4">
<td className="hidden w-2/12 whitespace-nowrap px-2 py-1 text-center sm:table-cell lg:px-6 lg:py-4">
<span
className="
inline-flex
Expand All @@ -129,7 +129,7 @@ function DashboardTableRow({
{service.image.resolvedName}
</span>
</td>
<td className="whitespace-nowrap px-2 py-1 text-center lg:px-6 lg:py-4">
<td className="w-3/12 whitespace-nowrap px-2 py-1 text-center lg:px-6 lg:py-4">
{service.hosts.map((host, index) => (
<a
href={`https://${host}`}
Expand Down Expand Up @@ -160,15 +160,15 @@ function DashboardTableRow({
</td>

<td
className="hidden whitespace-nowrap text-right text-xs font-medium lg:table-cell lg:px-6
lg:py-4 lg:text-sm"
className="hidden w-1/12 whitespace-nowrap text-right text-xs font-medium lg:table-cell
lg:px-6 lg:py-4 lg:text-sm"
>
<div className="m-2 flex justify-end">
{getActionIcon()}
</div>
</td>
<td
className="hidden whitespace-nowrap text-right text-xs font-medium lg:table-cell lg:px-6
className="hidden w-1/12 whitespace-nowrap text-right text-xs font-medium lg:table-cell lg:px-6
lg:py-4 lg:text-sm"
>
<button
Expand All @@ -182,7 +182,7 @@ function DashboardTableRow({
</button>
</td>
<td
className="hidden whitespace-nowrap text-right text-xs font-medium lg:table-cell lg:px-6
className="hidden w-1/12 whitespace-nowrap text-right text-xs font-medium lg:table-cell lg:px-6
lg:py-4 lg:text-sm"
>
<button
Expand All @@ -196,7 +196,7 @@ function DashboardTableRow({
</button>
</td>
<td
className="hidden whitespace-nowrap text-right text-xs font-medium lg:table-cell lg:px-6
className="hidden w-1/12 whitespace-nowrap text-right text-xs font-medium lg:table-cell lg:px-6
lg:py-4 lg:text-sm"
>
<button
Expand All @@ -209,7 +209,7 @@ function DashboardTableRow({
<CogIcon className="mr-2 h-5 w-5" />
</button>
</td>
<td className="hidden p-1 text-right lg:table-cell">
<td className="hidden w-1/12 p-1 text-right lg:table-cell">
<div className="m-2 flex justify-end">
<MenuIcon className="h-5 w-5" />
</div>
Expand Down
Loading

0 comments on commit 333741a

Please sign in to comment.