Set $NODE_ENV according to the image purpose during Docker build (#1088)

* Set $NODE_ENV according to the image purpose during Docker build

* Move `husky` from dev-deps to prod-deps, as it is used during prod `npm ci`

---------

Co-authored-by: Konstantin Koval <kkb@ukr.net>
This commit is contained in:
Kostiantyn
2024-10-04 12:20:49 +03:00
committed by GitHub
parent 7057643b5d
commit ff009a6ae6
6 changed files with 37 additions and 31 deletions

View File

@@ -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 }}

View File

@@ -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

View File

@@ -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}

View File

@@ -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"

6
ui/package-lock.json generated
View File

@@ -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",

View File

@@ -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",