Skip to content

Commit

Permalink
feat: create web UI (#44)
Browse files Browse the repository at this point in the history
Create a simple UI using React and Chakra UI

* Added eslint and prettier configurations
* Added header with search bar, GitHub link, and theme switch button
* Add dependabot.yml for UI dependencies

---------

Authored-by: Ehab Younes <ehab.alyounes@gmail.com>
  • Loading branch information
EhabY authored and m-adawi committed Sep 3, 2024
1 parent 10bd58e commit 8e326f7
Show file tree
Hide file tree
Showing 28 changed files with 7,113 additions and 5 deletions.
9 changes: 9 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
version: 2
updates:
- package-ecosystem: "npm"
directory: "/ui"
schedule:
interval: "weekly"
rebase-strategy: "auto"
labels:
- dependencies
1 change: 1 addition & 0 deletions .github/workflows/docker-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
- "**.go"
- "go.mod"
- "go.sum"
- "ui/**"
- "Dockerfile"
workflow_dispatch:

Expand Down
11 changes: 9 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
FROM golang:1.22.5 AS base
FROM node:22-alpine3.19 AS ui
WORKDIR /ui
COPY ui/package.json ui/package-lock.json .
RUN npm install
COPY ui/ .
RUN npm run build

FROM golang:1.22.5 AS backend
COPY go.mod go.sum ./
RUN go mod download
COPY cmd/ cmd/
Expand All @@ -11,5 +17,6 @@ RUN CGO_ENABLED=0 GOOS=linux go build -o /swarm-cd ./cmd/
FROM alpine:3.2
WORKDIR /app
RUN apk add --no-cache ca-certificates && update-ca-certificates
COPY --from=base /swarm-cd .
COPY --from=ui /ui/dist/ .
COPY --from=backend /swarm-cd .
CMD ["/app/swarm-cd"]
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ A declarative GitOps and Continuous Deployment tool for Docker Swarm.

Inspired by [ArgoCD](https://argo-cd.readthedocs.io/en/stable/).

![SwarmCD UI](assets/ui.png)

## Usage

In this example, we use SwarmCD to deploy the stack in the repo
Expand Down
Binary file added assets/ui.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 38 additions & 0 deletions ui/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
module.exports = {
root: true,
env: { browser: true, es2020: true },
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:react/recommended",
"plugin:react-hooks/recommended"
],
ignorePatterns: ["dist", ".eslintrc.cjs"],
parser: "@typescript-eslint/parser",
parserOptions: {
project: ["./tsconfig.app.json", "./tsconfig.node.json"],
tsconfigRootDir: __dirname
},
settings: {
react: {
version: "detect"
}
},
plugins: ["@typescript-eslint", "react", "react-hooks", "react-refresh"],
rules: {
"@typescript-eslint/explicit-function-return-type": [
"error",
{
allowExpressions: true,
allowTypedFunctionExpressions: true,
allowHigherOrderFunctions: true
}
],
"@typescript-eslint/no-unused-vars": "warn",
"@typescript-eslint/no-floating-promises": "error",
"@typescript-eslint/no-unsafe-assignment": "error",
"react-refresh/only-export-components": "warn",
"react-hooks/rules-of-hooks": "error",
"react-hooks/exhaustive-deps": "warn"
}
}
24 changes: 24 additions & 0 deletions ui/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
8 changes: 8 additions & 0 deletions ui/.prettierrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = {
singleQuote: false,
semi: false,
trailingComma: "none",
printWidth: 120,
tabWidth: 2,
arrowParens: "avoid"
}
4 changes: 4 additions & 0 deletions ui/.vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"recommendations": ["dbaeumer.vscode-eslint", "esbenp.prettier-vscode", "SonarSource.sonarlint-vscode"],
"unwantedRecommendations": []
}
42 changes: 42 additions & 0 deletions ui/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# SwarmCD UI

This repository contains the code for the SwarmCD UI, a web-based user interface for checking the deployment status. The UI is built using React and bundled by Vite for fast and efficient development and build processes.

## Installation

1. Install [NodeJs](https://nodejs.org/en/download/package-manager)
2. Install dependencies `npm install`
3. To run the development UI server `npm run dev`
4. To build for production `npm run build`
- The production build will be output to the `dist` directory.

## Directory structure

```text
swarm-cd-ui/
├── public/ # Static assets
├── src/ # Source files
│ ├── assets/ # Images, fonts, etc.
│ ├── components/ # React components
│ ├── hooks/ # React hooks
│ ├── App.tsx # Main App component
│ ├── index.tsx # Entry point
├── package.json # Project metadata and scripts
└── vite.config.ts # Vite configuration
```

Recommended `.vscode/settings.json`:

```json
{
"editor.codeActionsOnSave": {
"source.organizeImports": "always",
"source.fixAll.eslint": "always"
},
"editor.tabSize": 2,
"editor.formatOnSave": true,
"eslint.format.enable": true,
"eslint.lintTask.enable": true,
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
```
12 changes: 12 additions & 0 deletions ui/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>SwarmCD</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
Loading

0 comments on commit 8e326f7

Please sign in to comment.