fix: add ui production target + improve code

This commit is contained in:
Emnaghz 2024-09-27 18:23:48 +01:00
parent 615402c88b
commit c2f6b5af7b
4 changed files with 31 additions and 33 deletions

View File

@ -58,6 +58,7 @@ jobs:
file: ./frontend/Dockerfile file: ./frontend/Dockerfile
platforms: linux/amd64,linux/arm64 platforms: linux/amd64,linux/arm64
push: true push: true
target: production
tags: hexastack/hexabot-ui:latest tags: hexastack/hexabot-ui:latest
- name: Build and push API Docker image - name: Build and push API Docker image

View File

@ -49,8 +49,6 @@ services:
- WATCHPACK_POLLING=true - WATCHPACK_POLLING=true
volumes: volumes:
- ../frontend/:/app/frontend/ - ../frontend/:/app/frontend/
ports:
- 8081:8081
widget: widget:
build: build:

View File

@ -41,11 +41,29 @@ RUN \
else echo "Lockfile not found." && exit 1; \ else echo "Lockfile not found." && exit 1; \
fi fi
# Production image, copy all the files and run next FROM base AS development
FROM base AS runner
WORKDIR /app
COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* ./
COPY . .
RUN npm install
ENV NODE_ENV=development
ENV CHOKIDAR_USEPOLLING=true
ENV WATCHPACK_POLLING=true
WORKDIR /app/frontend WORKDIR /app/frontend
ENV NODE_ENV production CMD ["npm", "run", "dev", "--", "-p", "8080"]
# Production image, copy all the files and run next
FROM base AS production
WORKDIR /app/frontend
ENV NODE_ENV=production
# Uncomment the following line in case you want to disable telemetry during runtime. # Uncomment the following line in case you want to disable telemetry during runtime.
ENV NEXT_TELEMETRY_DISABLED 1 ENV NEXT_TELEMETRY_DISABLED 1
@ -73,23 +91,3 @@ ENV PORT 8080
# server.js is created by next build from the standalone output # server.js is created by next build from the standalone output
# https://nextjs.org/docs/pages/api-reference/next-config-js/output # https://nextjs.org/docs/pages/api-reference/next-config-js/output
CMD HOSTNAME="0.0.0.0" node server.js CMD HOSTNAME="0.0.0.0" node server.js
FROM base AS development
WORKDIR /app
COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* ./
COPY . .
RUN npm install
ENV NODE_ENV=development
ENV CHOKIDAR_USEPOLLING=true
ENV WATCHPACK_POLLING=true
EXPOSE 8081
WORKDIR /app/frontend
CMD ["npm", "run", "dev"]

View File

@ -10,15 +10,16 @@ const nextConfig = withTM(["hexabot-widget"])({
}, },
]; ];
}, },
webpack: (config => { webpack(config) {
if(process.env.NODE_ENV=="development"){
config.watchOptions = { config.watchOptions = {
poll: 1000, poll: 1000,
aggregateTimeout: 300, aggregateTimeout: 300,
// ignored: ['**/node_modules'] };
} }
return config return config;
}), },
publicRuntimeConfig: { publicRuntimeConfig: {
lang: { lang: {
default: "en", default: "en",