Skip to content
This repository has been archived by the owner on Apr 14, 2024. It is now read-only.

Migrate to new repo #103

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 0 additions & 23 deletions .github/workflows/deploy-dev.yml

This file was deleted.

23 changes: 0 additions & 23 deletions .github/workflows/deploy-prod.yml

This file was deleted.

32 changes: 32 additions & 0 deletions .github/workflows/deploy-production.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Deploy Production
on:
push:
tags:
- "v*.*.*"
workflow_dispatch:
jobs:
build:
runs-on: [self-hosted, builder]
steps:
- name: Set environment variables
run: >
for e in $(env | grep "COLLABRY__BUILDER__");
do echo "${e#'COLLABRY__BUILDER__'}" >> $GITHUB_ENV;
done
- name: Checkout
uses: actions/checkout@v4
- name: Build docker image
run: >
docker build
-t "${REGISTRY_DOMAIN}/collabry/frontend:${{ github.sha }}"
-t "${REGISTRY_DOMAIN}/collabry/frontend:production"
--build-arg "API_BASE_URL=https://api.${production__DOMAIN}"
--target slim .
- name: Login docker registry
run: docker login "${REGISTRY_DOMAIN}" -u "${REGISTRY_USER}" -p "${REGISTRY_PASSWORD}"
- name: Push docker image
run: docker push "${REGISTRY_DOMAIN}/collabry/frontend:production" --all-tags
deploy:
uses: collabry-space/deploy/.github/workflows/deploy.yaml@main
with:
env: production
32 changes: 32 additions & 0 deletions .github/workflows/deploy-stage.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Deploy Stage
on:
push:
branches:
- main
workflow_dispatch:
jobs:
build:
runs-on: [self-hosted, builder]
steps:
- name: Set environment variables
run: >
for e in $(env | grep "COLLABRY__BUILDER__");
do echo "${e#'COLLABRY__BUILDER__'}" >> $GITHUB_ENV;
done
- name: Checkout
uses: actions/checkout@v4
- name: Build docker image
run: >
docker build
-t "${REGISTRY_DOMAIN}/collabry/frontend:${{ github.sha }}"
-t "${REGISTRY_DOMAIN}/collabry/frontend:stage"
--build-arg "API_BASE_URL=https://api.${stage__DOMAIN}"
--target slim .
- name: Login docker registry
run: docker login "${REGISTRY_DOMAIN}" -u "${REGISTRY_USER}" -p "${REGISTRY_PASSWORD}"
- name: Push docker image
run: docker push "${REGISTRY_DOMAIN}/collabry/frontend:stage" --all-tags
deploy:
uses: collabry-space/deploy/.github/workflows/deploy.yaml@main
with:
env: stage
49 changes: 49 additions & 0 deletions .github/workflows/integration.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Integration
on: [push, workflow_dispatch]
jobs:
build:
runs-on: [self-hosted, builder]
steps:
- name: Set environment variables
run: >
for e in $(env | grep "COLLABRY__BUILDER__");
do echo "${e#'COLLABRY__BUILDER__'}" >> $GITHUB_ENV;
done
- name: Checkout
uses: actions/checkout@v4
- name: Build docker image
run: docker build -t "${REGISTRY_URL}/collabry/frontend:${{ github.sha }}" --target full .
- name: Login docker registry
run: docker login "${REGISTRY_DOMAIN}" -u "${REGISTRY_USER}" -p "${REGISTRY_PASSWORD}"
- name: Push docker image
run: docker push "${REGISTRY_DOMAIN}/collabry/frontend:${{ github.sha }}"
lint:
needs: [build]
runs-on: [self-hosted, integration]
steps:
- name: Set environment variables
run: >
for e in $(env | grep "COLLABRY__INTEGRATION__");
do echo "${e#'COLLABRY__INTEGRATION__'}" >> $GITHUB_ENV;
done
- name: Login docker registry
run: docker login "${REGISTRY_DOMAIN}" -u "${REGISTRY_USER}" -p "${REGISTRY_PASSWORD}"
- name: Pull docker image
run: docker pull "${REGISTRY_DOMAIN}/collabry/frontend:${{ github.sha }}"
- name: Lint
run: docker run --rm "${REGISTRY_DOMAIN}/collabry/frontend:${{ github.sha }}" lint
test:
needs: [build]
runs-on: [self-hosted, integration]
steps:
- name: Set environment variables
run: >
for e in $(env | grep "COLLABRY__INTEGRATION__");
do echo "${e#'COLLABRY__INTEGRATION__'}" >> $GITHUB_ENV;
done
- name: Login docker registry
run: docker login "${REGISTRY_DOMAIN}" -u "${REGISTRY_USER}" -p "${REGISTRY_PASSWORD}"
- name: Pull docker image
run: docker pull "${REGISTRY_DOMAIN}/collabry/frontend:${{ github.sha }}"
- name: Isort
run: docker run --rm "${REGISTRY_DOMAIN}/collabry/frontend:${{ github.sha }}" test
22 changes: 0 additions & 22 deletions .github/workflows/pull-request.yml

This file was deleted.

8 changes: 4 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
node_modules
dist
*.local
.yarn/*
!.yarn/cache
Expand All @@ -8,8 +6,10 @@ dist
!.yarn/releases
!.yarn/sdks
!.yarn/versions
stats.html
.cache
.eslintcache
.DS_Store
dev-dist
dev-dist
dist
stats.html
node_modules
37 changes: 37 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
FROM node:18-slim as core

WORKDIR /app

COPY ./package.json /app/package.json
COPY ./yarn.lock /app/yarn.lock
COPY ./.yarn /app/.yarn
COPY ./.yarnrc.yml /app/.yarnrc.yml
RUN yarn --immutable

COPY ./public /app/public
COPY ./src /app/src
COPY ./index.html /app/index.html
COPY ./vite.config.ts /app/vite.config.ts

FROM core as build

ARG API_BASE_URL
ENV VITE_API_BASE_URL=${API_BASE_URL}

RUN yarn build

FROM core as full

COPY ./tests /app/tests
COPY ./.eslintignore /app/.eslintignore
COPY ./.eslintrc.js /app/.eslintrc.js
COPY ./.prettierrc.js /app/.prettierrc.js
COPY ./commitlint.config.js /app/commitlint.config.js
COPY ./tsconfig.json /app/tsconfig.json
COPY ./tsconfig.node.json /app/tsconfig.node.json
COPY ./types /app/types
ENTRYPOINT ["yarn"]

FROM nginx:alpine-slim as slim

COPY --from=build /app/dist /usr/share/nginx/html
16 changes: 4 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,12 @@
# Sapphire

### Ссылки на проект:

- [stage.sapphire.pet-project.habr.com](https://stage.sapphire.pet-project.habr.com)
- [sapphire.pet-project.habr.com](https://sapphire.pet-project.habr.com)

[Бекенд репозиторий](https://github.com/habralab/sapphire-team-back)
[Figma](https://www.figma.com/file/0NelvdkD6gTqKrWfRYydI2/)
[Task manager](https://tree.taiga.io/project/olegyurchik-sapphire-habr/timeline)

Установка зависимостей:
### Установка зависимостей

```
yarn
```

Разработка проекта:
### Разработка проекта

```
yarn dev
Expand All @@ -39,7 +30,8 @@ yarn test:watch

Качество кода проверяется такие инструментами как prettier, eslint, tsc.

IDE автоматически показывает эти ошибки. Если есть возможность, то prettier и eslint ошибки исправляются в момент сохранения файла, а также в момент коммита.
IDE автоматически показывает эти ошибки. Если есть возможность, то prettier и eslint ошибки
исправляются в момент сохранения файла, а также в момент коммита.

typescript ошибки необходимо исправлять самому, т.к. только мы ведуем про типизацию.

Expand Down
15 changes: 2 additions & 13 deletions src/app/providers/router/Router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,7 @@ import { api } from '~/shared/api';

import { Layout } from './Layout';

const closedRouter = createBrowserRouter([
{
path: '*',
element: <BlankPage />,
},
]);

const normalRouter = createBrowserRouter([
const router = createBrowserRouter([
{
path: '*',
element: <Layout />,
Expand All @@ -31,9 +24,5 @@ const normalRouter = createBrowserRouter([
]);

export const RouterProvider = () => {
return (
<ReactRouterProvider
router={import.meta.env.VITE_CLOSED ? closedRouter : normalRouter}
/>
);
return <ReactRouterProvider router={router} />;
};
2 changes: 1 addition & 1 deletion src/shared/api/clients/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export class BaseApiClient {
this.baseURL = `${import.meta.env.VITE_API_BASE_URL}${domainURL}`;

this.client = axios.create({
baseURL: import.meta.env.DEV ? `/backend${domainURL}` : this.baseURL,
baseURL: this.baseURL,
});

this.client.interceptors.response.use(
Expand Down
2 changes: 1 addition & 1 deletion src/shared/lib/const.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export const TIME = {
DEBOUNCE: 1000,
DEBOUNCE: 500,
};
8 changes: 0 additions & 8 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ export default defineConfig({
injectRegister: null,
workbox: {
globPatterns: ['**/*.{js,css,html,woff,woff2,svg}'],
navigateFallbackDenylist: [/^\/backend/],
},
includeAssets: [
'/favicon.ico',
Expand Down Expand Up @@ -72,13 +71,6 @@ export default defineConfig({
},
server: {
https: true,
proxy: {
'/backend': {
target: process.env.VITE_API_BASE_URL,
changeOrigin: true,
rewrite: (path) => path.replace(/^\/backend/, ''),
},
},
},
cacheDir: '.yarn/.vite',
resolve: {
Expand Down
Loading