Skip to content

Commit

Permalink
refactor(ci): mix ui and api in one repo
Browse files Browse the repository at this point in the history
  • Loading branch information
Mihoub2 committed Sep 17, 2024
1 parent 977fc39 commit 3fa33f3
Show file tree
Hide file tree
Showing 188 changed files with 50,981 additions and 7,538 deletions.
25 changes: 18 additions & 7 deletions .github/workflows/staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,34 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18
- uses: oven-sh/setup-bun@v2

- name: 🔑 Login Docker
run: docker login ghcr.io -u ${{ github.actor }} -p ${{ secrets.GITHUB_TOKEN }}

- name: 🐳 Build Docker image
- name: Build client (Vite.js)
run: |
IMAGE_ID=ghcr.io/${{ github.repository }}
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
docker build -t $IMAGE_ID:staging .
npm i --prefix client
npm run build --prefix client
- name: Move client build to server
run: mv client/dist/* server/public/

- name: Build server (Bun)
run: |
cd server
bun install
docker build -t ${{ github.repository }} .
- name: Get Tag
id: version
run: echo "tag=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT

- name: 📦 Push Docker image
run: |
IMAGE_ID=ghcr.io/${{ github.repository }}
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
docker tag ${{ github.repository }} $IMAGE_ID:staging
docker push $IMAGE_ID:staging
deploy:
Expand Down
20 changes: 11 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
FROM node:18-alpine AS build
FROM oven/bun

WORKDIR /app
COPY package*.json ./
RUN npm ci --silent
COPY . .
RUN npm run build

FROM nginx:stable
COPY nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 5173

COPY ./server/package.json .
RUN bun i --production
COPY ./server .

ENV NODE_ENV=production
CMD ["bun", "run", "index.ts"]

EXPOSE 3000
2 changes: 1 addition & 1 deletion index.html → client/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@

<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
<script type="module" src="/main.tsx"></script>
</body>
</html>
2 changes: 1 addition & 1 deletion src/main.tsx → client/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import "react-toastify/dist/ReactToastify.min.css";

import Router from "./router";
import { DSFRConfig } from "@dataesr/dsfr-plus";
import { DataListProvider } from "./pages/api-operation-page/link-publications/data-list-context";
import { DataListProvider } from "./src/pages/api-operation-page/link-publications/data-list-context";

const queryClient = new QueryClient({
defaultOptions: {
Expand Down
Loading

0 comments on commit 3fa33f3

Please sign in to comment.