diff --git a/Dockerfile b/Dockerfile index 87fef34..9b9e83b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,6 +11,10 @@ FROM node:20-alpine AS builder WORKDIR /app ENV NEXT_TELEMETRY_DISABLED=1 +ARG NEXT_PUBLIC_API_URL +ARG NODE_ENV +ENV NODE_ENV=$NODE_ENV +ENV NEXT_PUBLIC_API_URL=$NEXT_PUBLIC_API_URL COPY --from=deps /app/node_modules ./node_modules COPY . . RUN npm run build @@ -18,9 +22,16 @@ RUN npm run build # Runtime stage FROM node:20-alpine AS runner WORKDIR /app + +# Accept build args and set as env vars +ARG NEXT_PUBLIC_API_URL +ARG PORT=3000 + ENV NODE_ENV=production ENV NEXT_TELEMETRY_DISABLED=1 -ENV PORT=3000 +ENV PORT=$PORT +ENV HOSTNAME=0.0.0.0 +ENV NEXT_PUBLIC_API_URL=$NEXT_PUBLIC_API_URL # Install prod deps only for runtime COPY package*.json ./ @@ -31,5 +42,6 @@ COPY --from=builder /app/.next ./.next COPY --from=builder /app/public ./public COPY --from=builder /app/next.config.* ./ -EXPOSE 3000 -CMD ["npm", "start"] +EXPOSE $PORT + +CMD ["sh", "-c", "node_modules/.bin/next start -H ${HOSTNAME} -p ${PORT}"] \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 0038380..3d8d3f2 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,10 +5,16 @@ services: build: context: . dockerfile: Dockerfile + args: + NEXT_PUBLIC_API_URL: http://localhost:3000 + NODE_ENV: production + PORT: 3002 image: ibank-frontend:latest environment: - NODE_ENV=production - NEXT_PUBLIC_API_URL=http://localhost:3000 + - PORT=3000 + - HOSTNAME=0.0.0.0 ports: - "5836:3000" restart: unless-stopped diff --git a/package.json b/package.json index 04dd927..7cbdddd 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "version": "1.0.0", "private": true, "scripts": { - "dev": "next dev -- -p 5836", + "dev": "next dev", "build": "next build", "start": "next start", "generate:db-types": "node scripts/generate-db-types.js", diff --git a/src/components/ParametersList.tsx b/src/components/ParametersList.tsx index 8e39e45..1a57776 100644 --- a/src/components/ParametersList.tsx +++ b/src/components/ParametersList.tsx @@ -12,6 +12,9 @@ export default function ParametersList({ userId }: { userId: string }) { { name: "param_value", label: "Value" }, { name: "is_active", label: "Active" }, ]} + where={{ + user_id: userId, + }} addSectionLabel="Add Parameter" addSectionUrl={`/d/user/${userId}/parameter/new`} urlData={`/d/user/${userId}/parameter/:parameter_id`} diff --git a/src/components/UserAccessList.tsx b/src/components/UserAccessList.tsx index 85f7235..0a85feb 100644 --- a/src/components/UserAccessList.tsx +++ b/src/components/UserAccessList.tsx @@ -12,6 +12,9 @@ export default function UserAccessList({ userId }: { userId: string }) { { name: "access_value", label: "Value" }, { name: "is_active", label: "Active" }, ]} + where={{ + user_id: userId, + }} addSectionLabel="Add Access" addSectionUrl={`/d/user/${userId}/access/new`} urlData={`/d/user/${userId}/access/:access_id`}