From e47115036ee1d77860a7257a1644a7f398128db3 Mon Sep 17 00:00:00 2001 From: NeonXP Date: Sun, 21 Jan 2024 17:49:35 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9F=D1=80=D0=BE=D0=BA=D0=B8=D0=B4=D1=8B?= =?UTF-8?q?=D0=B2=D0=B0=D0=BD=D0=B8=D0=B5=20=D0=B2=D0=B5=D1=80=D1=81=D0=B8?= =?UTF-8?q?=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .woodpecker.yaml | 7 ++++--- Dockerfile | 14 ++++---------- frontend/src/main.jsx | 2 ++ frontend/src/pages/admin/Quest.jsx | 5 +++++ frontend/vite.config.js | 2 +- main.go | 6 +++++- 6 files changed, 21 insertions(+), 15 deletions(-) create mode 100644 frontend/src/pages/admin/Quest.jsx diff --git a/.woodpecker.yaml b/.woodpecker.yaml index 9e8f5a8..bf6b4f2 100644 --- a/.woodpecker.yaml +++ b/.woodpecker.yaml @@ -1,11 +1,12 @@ steps: build: - image: plugins/docker + image: woodpeckerci/plugin-docker-buildx settings: registry: gitrepo.ru username: neonxp password: from_secret: gitea_token repo: gitrepo.ru/neonxp/nquest - tags: latest - auto_tag: true \ No newline at end of file + tags: + - latest + - ${CI_COMMIT_SHA} \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index c23458a..324c107 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,19 +1,21 @@ # Build frontend FROM node:21-alpine3.17 as frontend +ARG VERSION WORKDIR /app COPY ./frontend /app RUN echo "@neonxp:registry=https://gitrepo.ru/api/packages/neonxp/npm/" > ~/.npmrc -RUN npm install && npm run build +RUN npm install && VITE_VERSION=${VERSION} npm run build # Build backend FROM golang:1.21.3-alpine3.17 as backend +ARG VERSION WORKDIR /app RUN apk update --no-cache && apk add --no-cache tzdata COPY go.mod go.sum ./ RUN go mod download && go mod verify COPY . . COPY --from=frontend /app/dist /app/frontend/dist -RUN go build -o nquest *.go +RUN go build -ldflags="-X gitrepo.ru/neonxp/nquest.Version=${VERSION}" -o nquest *.go # Runtime container FROM alpine:3.17 @@ -25,14 +27,6 @@ COPY --from=backend /app/nquest /app/nquest ENV TZ Europe/Moscow -ENV PG_HOST nquestdb -ENV PG_NAME nquest -ENV PG_USER nquest -ENV PG_PASS nquest -ENV PG_PORT 5432 -ENV SECRET s3cr3t -ENV LISTEN :8000 - EXPOSE 8000 CMD ["/app/nquest"] \ No newline at end of file diff --git a/frontend/src/main.jsx b/frontend/src/main.jsx index c9fef37..122a17e 100644 --- a/frontend/src/main.jsx +++ b/frontend/src/main.jsx @@ -9,6 +9,8 @@ import App from './App.jsx' import { store } from './store/provider.js' const { darkAlgorithm } = theme +console.log(import.meta.env.VITE_VERSION) + ReactDOM.createRoot(document.getElementById('root')).render( diff --git a/frontend/src/pages/admin/Quest.jsx b/frontend/src/pages/admin/Quest.jsx new file mode 100644 index 0000000..36eda13 --- /dev/null +++ b/frontend/src/pages/admin/Quest.jsx @@ -0,0 +1,5 @@ +const Quest = () => { + +} + +export default Quest diff --git a/frontend/vite.config.js b/frontend/vite.config.js index 44d960d..06d8b13 100644 --- a/frontend/vite.config.js +++ b/frontend/vite.config.js @@ -61,7 +61,7 @@ const manifest = { // https://vitejs.dev/config/ export default defineConfig({ - plugins: [react(), splitVendorChunkPlugin(), VitePWA(manifest)], + plugins: [react(), splitVendorChunkPlugin()/* , VitePWA(manifest) */], server: { proxy: { '/api': { diff --git a/main.go b/main.go index 4fb4ecb..22b8a4c 100644 --- a/main.go +++ b/main.go @@ -25,6 +25,10 @@ import ( "gitrepo.ru/neonxp/nquest/pkg/service" ) +var ( + Version = "dev" +) + func main() { cfg, err := GetConfig() if err != nil { @@ -177,7 +181,7 @@ func main() { // --[ System ]-- e.GET("/metrics", echoprometheus.NewHandler()) - + e.Logger.Debugf("backend version %s", Version) e.Logger.Fatal(e.Start(cfg.Listen)) }