From 7750272cb1c3c8cb017ca98c83608987db667dc2 Mon Sep 17 00:00:00 2001 From: Aleksey Zverev Date: Wed, 8 Nov 2023 21:52:36 +0200 Subject: [PATCH] Add UI deploy --- .github/workflows/release.yml | 4 ++-- .gitignore | 4 +++- Dockerfile | 44 ++++++++++++++++++++++++++++++++--- website/package-lock.json | 10 ++++---- website/package.json | 4 ++-- 5 files changed, 53 insertions(+), 13 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 498e449..2bdd106 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -228,8 +228,8 @@ jobs: - name: Build and push app uses: docker/build-push-action@v4 with: - context: ./web - file: ./web/Dockerfile + context: . + file: ./Dockerfile push: true tags: ghcr.io/${{ github.actor }}/yoda-web:latest,ghcr.io/${{ github.actor }}/yoda-web:${{ steps.get-version.outputs.substring }} release: diff --git a/.gitignore b/.gitignore index f6c06a7..55b9a1e 100644 --- a/.gitignore +++ b/.gitignore @@ -23,4 +23,6 @@ build coverage.html **/.docker-conf/** .* -.data \ No newline at end of file +.data + +**/node_modules/** \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 9e7f0d9..2d68cd9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,48 @@ -FROM node +FROM node as build-ui WORKDIR /app +RUN npm i tar RUN npm install -g create-react-app RUN npm install -g openapi -COPY website /app +COPY website/src /app/src +COPY website/package.json /app +COPY website/package-lock.json /app +COPY website/public /app/public +COPY website/tsconfig.json /app -ENTRYPOINT ["bash"] \ No newline at end of file +COPY web/openapi/openapi.yml /app/openapi.yml +RUN npm run build + +## Build +FROM golang:1.20 AS build-backend + +WORKDIR /app + +COPY web/cmd ./cmd +COPY web/internal ./internal +COPY web/openapi ./openapi +COPY web/go.mod ./go.mod +COPY web/go.sum ./go.sum +COPY web/Makefile ./Makefile + +RUN go mod download + +RUN make build + +## Deploy +FROM centos:7 + +WORKDIR /app + +COPY web/openapi /app/openapi +COPY --from=build-ui /app/build /app/public + +VOLUME /tmp + +EXPOSE 8080 + +COPY --from=build-backend /app/build/web-amd64-linux /app/web-amd64-linux + +ENTRYPOINT ["/app/web-amd64-linux"] \ No newline at end of file diff --git a/website/package-lock.json b/website/package-lock.json index 0bbb10b..04418ee 100644 --- a/website/package-lock.json +++ b/website/package-lock.json @@ -23,7 +23,7 @@ "react-dom": "18.2.0", "react-highlight-words": "^0.20.0", "react-router-dom": "^6.15.0", - "typescript": "5.1.6" + "typescript": "4.9.5" }, "devDependencies": { "@babel/plugin-proposal-private-property-in-object": "^7.21.11", @@ -19204,15 +19204,15 @@ } }, "node_modules/typescript": { - "version": "5.1.6", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.1.6.tgz", - "integrity": "sha512-zaWCozRZ6DLEWAWFrVDz1H6FVXzUSfTy5FUMWsQlU8Ym5JP9eO4xkTIROFCQvhQf61z6O/G6ugw3SgAnvvm+HA==", + "version": "4.9.5", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz", + "integrity": "sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==", "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" }, "engines": { - "node": ">=14.17" + "node": ">=4.2.0" } }, "node_modules/uglify-js": { diff --git a/website/package.json b/website/package.json index a4b4f2c..182ee0f 100755 --- a/website/package.json +++ b/website/package.json @@ -15,7 +15,7 @@ "react-dom": "18.2.0", "react-highlight-words": "^0.20.0", "react-router-dom": "^6.15.0", - "typescript": "5.1.6" + "typescript": "4.9.5" }, "devDependencies": { "@babel/plugin-proposal-private-property-in-object": "^7.21.11", @@ -31,7 +31,7 @@ "test": "react-scripts test --env=jsdom", "eject": "react-scripts eject", "generate": "openapi --input ./openapi.yml --output ./src/client --client fetch", - "clean": "rm -rf ./build ./node_modules" + "clean": "rm -rf ./build/* ./node_modules" }, "name": "f8q3qh", "version": "0.0.0",