diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3cb61d18..04772b63 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -124,6 +124,7 @@ jobs: cache-from: type=gha cache-to: type=gha,mode=max build-args: | + NODE_ENV=production VERSION=${{ github.ref_name }} COMMIT_SHA=${{ github.sha }} diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 88e42b33..630b4e50 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -105,6 +105,8 @@ jobs: tags: photoview/ui cache-from: type=gha cache-to: type=gha,mode=max + build-args: | + NODE_ENV=testing - name: Test id: test diff --git a/Dockerfile b/Dockerfile index 5562763a..7900378e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,6 +4,9 @@ FROM --platform=${BUILDPLATFORM:-linux/amd64} node:18 AS ui # See for details: https://github.com/hadolint/hadolint/wiki/DL4006 SHELL ["/bin/bash", "-euo", "pipefail", "-c"] +ARG NODE_ENV +ENV NODE_ENV=${NODE_ENV:-production} + ARG REACT_APP_API_ENDPOINT ENV REACT_APP_API_ENDPOINT=${REACT_APP_API_ENDPOINT} diff --git a/dev-compose.yaml b/dev-compose.yaml index 5ca1a408..10861f44 100644 --- a/dev-compose.yaml +++ b/dev-compose.yaml @@ -7,17 +7,19 @@ services: context: . dockerfile: Dockerfile target: ui + args: + - NODE_ENV=development env_file: ui/example.env volumes: - - .:/app:rw + - .:/app:rw ports: - - 1234:1234 + - 1234:1234 command: - - /bin/bash - - -c - - | - npm ci - npm run mon + - /bin/bash + - -c + - | + npm ci + npm run mon dev-api: image: photoview/api @@ -32,20 +34,20 @@ services: PHOTOVIEW_MYSQL_URL: photoview:photosecret@tcp(mysql)/photoview_test PHOTOVIEW_POSTGRES_URL: postgres://photoview:photosecret@postgres:5432/photoview_test volumes: - - .:/app:rw + - .:/app:rw ports: - - 4001:4001 + - 4001:4001 command: - - /bin/bash - - -c - - | - export $(cat /env) - reflex -g '*.go' -s -- go run . + - /bin/bash + - -c + - | + export $(cat /env) + reflex -g '*.go' -s -- go run . mariadb: image: mariadb:lts profiles: - - mysql + - mysql environment: MYSQL_DATABASE: photoview_test MYSQL_USER: photoview @@ -53,31 +55,31 @@ services: MYSQL_RANDOM_ROOT_PASSWORD: yes healthcheck: test: - - CMD - - mariadb-admin - - --user=photoview - - --password=photosecret - - ping + - CMD + - mariadb-admin + - --user=photoview + - --password=photosecret + - ping interval: 20s timeout: 5s retries: 10 expose: - - "3306" + - "3306" postgres: image: postgres:16-alpine profiles: - - postgres + - postgres environment: POSTGRES_DB: photoview_test POSTGRES_USER: photoview POSTGRES_PASSWORD: photosecret healthcheck: test: - - CMD - - pg_isready + - CMD + - pg_isready interval: 20s timeout: 5s retries: 10 expose: - - "5432" + - "5432" diff --git a/ui/package-lock.json b/ui/package-lock.json index 2b34c5ad..b8b93fda 100644 --- a/ui/package-lock.json +++ b/ui/package-lock.json @@ -27,6 +27,7 @@ "classnames": "^2.3.1", "connect-history-api-fallback": "^2.0.0", "copy-to-clipboard": "^3.3.1", + "husky": "^8.0.1", "i18next": "^21.8.13", "mapbox-gl": "^2.9.1", "postcss": "^8.4.39", @@ -60,7 +61,6 @@ "c8": "^7.11.3", "eslint": "^8.19.0", "eslint-config-prettier": "^8.5.0", - "husky": "^8.0.1", "i18next-parser": "^8.13.0", "lint-staged": "^13.0.3", "nodemon": "^3.1.4", @@ -8021,7 +8021,6 @@ "version": "8.0.1", "resolved": "https://registry.npmjs.org/husky/-/husky-8.0.1.tgz", "integrity": "sha512-xs7/chUH/CKdOCs7Zy0Aev9e/dKOMZf3K1Az1nar3tzlv0jfqnYtu235bstsWTmXOR0EfINrPa97yy4Lz6RiKw==", - "dev": true, "bin": { "husky": "lib/bin.js" }, @@ -20133,8 +20132,7 @@ "husky": { "version": "8.0.1", "resolved": "https://registry.npmjs.org/husky/-/husky-8.0.1.tgz", - "integrity": "sha512-xs7/chUH/CKdOCs7Zy0Aev9e/dKOMZf3K1Az1nar3tzlv0jfqnYtu235bstsWTmXOR0EfINrPa97yy4Lz6RiKw==", - "dev": true + "integrity": "sha512-xs7/chUH/CKdOCs7Zy0Aev9e/dKOMZf3K1Az1nar3tzlv0jfqnYtu235bstsWTmXOR0EfINrPa97yy4Lz6RiKw==" }, "hyperlinker": { "version": "1.0.0", diff --git a/ui/package.json b/ui/package.json index 201ae655..2aea85f3 100644 --- a/ui/package.json +++ b/ui/package.json @@ -58,7 +58,8 @@ "tailwindcss": "npm:@tailwindcss/postcss7-compat@^2.2.17", "url-join": "^5.0.0", "vite": "^2.9.13", - "vite-plugin-svgr": "^2.2.0" + "vite-plugin-svgr": "^2.2.0", + "husky": "^8.0.1" }, "devDependencies": { "@testing-library/jest-dom": "^5.16.4", @@ -72,7 +73,6 @@ "c8": "^7.11.3", "eslint": "^8.19.0", "eslint-config-prettier": "^8.5.0", - "husky": "^8.0.1", "i18next-parser": "^8.13.0", "lint-staged": "^13.0.3", "nodemon": "^3.1.4",