Skip to content

Commit

Permalink
Merge pull request #22 from meta-panic/build/run-tests-frontend-deploy
Browse files Browse the repository at this point in the history
[bruno]Build/run tests frontend deploy
  • Loading branch information
meta-panic authored Jan 7, 2025
2 parents b2a8cc0 + 58f64b9 commit 28e8245
Show file tree
Hide file tree
Showing 11 changed files with 194 additions and 435 deletions.
2 changes: 1 addition & 1 deletion cms/run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ run_tests() {
if [ "$NODE_ENV" == "development" ]; then
npm run bru-local
elif [ "$NODE_ENV" == "production" ]; then
npm run bru-prod
npm run bru-local # because containers use localhost
else
echo "NODE_ENV is not set or has an invalid value. Please set it to 'development' or 'production'."
exit 1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
vars {
baseStrapiAdminUrl: http://localhost:1337
baseStrapiAdminUrl: http://127.0.0.1:1337
}
20 changes: 14 additions & 6 deletions dev-config/Dockerfile.frontend.dev
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,13 @@ FROM node:18-alpine

WORKDIR /app

# Install bash and curl
RUN apk add --no-cache bash curl

# Install dependencies based on the preferred package manager
COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* .npmrc* ./
RUN npm install -g @usebruno/[email protected]

RUN \
if [ -f yarn.lock ]; then yarn --frozen-lockfile; \
elif [ -f package-lock.json ]; then npm ci; \
Expand All @@ -18,6 +23,9 @@ COPY src ./src
COPY public ./public
COPY next.config.ts .
COPY tsconfig.json .
COPY tests ./tests
COPY run.sh ./
COPY run-tests.sh ./

# Next.js collects completely anonymous telemetry data about general usage. Learn more here: https://nextjs.org/telemetry
# Uncomment the following line to disable telemetry at run time
Expand All @@ -26,9 +34,9 @@ COPY tsconfig.json .
# Note: Don't expose ports here, Compose will handle that for us

# Start Next.js in development mode based on the preferred package manager
CMD \
if [ -f yarn.lock ]; then yarn dev; \
elif [ -f package-lock.json ]; then npm run dev; \
elif [ -f pnpm-lock.yaml ]; then pnpm dev; \
else npm run dev; \
fi

RUN chmod +x ./run.sh
RUN chmod +x ./run-tests.sh

# Start Next.js in development mode after running tests
CMD bash -c "./run-tests.sh docker & ./run.sh"
12 changes: 10 additions & 2 deletions dev-config/Dockerfile.frontend.prod
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ RUN npm run build
# Production image, copy all the files and run next
FROM base AS runner
WORKDIR /app
RUN apk add --no-cache bash
RUN apk add --no-cache bash curl
RUN npm install -g @usebruno/[email protected]

# Uncomment the following line in case you want to disable telemetry during runtime.
# ENV NEXT_TELEMETRY_DISABLED=1
Expand All @@ -44,8 +45,15 @@ COPY --from=builder /app/public ./public
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static

COPY tests ./tests
COPY run.sh ./
COPY run-tests.sh ./

RUN chmod +x ./run.sh
RUN chmod +x ./run-tests.sh

USER nextjs

RUN ls -la /app

CMD ["node", "server.js"]
CMD bash -c "./run-tests.sh docker & ./run.sh"
5 changes: 5 additions & 0 deletions dev-config/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
services:
frontend:
tty: true
build:
context: ../frontend
dockerfile: ../dev-config/Dockerfile.frontend.prod
Expand All @@ -11,6 +12,8 @@ services:
HOSTNAME: ${FRONTEND_HOSTNAME}
NEXT_PUBLIC_BACKEND_URL: ${NEXT_PUBLIC_BACKEND_URL}
NODE_ENV: ${NODE_ENV}
PROD_FRONT_URL: ${PROD_FRONT_URL}
PROD_STRAPI_URL: ${PROD_STRAPI_URL}
networks:
- strapi
cms:
Expand Down Expand Up @@ -42,6 +45,8 @@ services:
DATABASE_PORT: ${DATABASE_PORT}
DATABASE_SSL: "false"
NODE_ENV: ${NODE_ENV}
PROD_FRONT_URL: ${PROD_FRONT_URL}
PROD_STRAPI_URL: ${PROD_STRAPI_URL}
volumes:
- photos:/usr/app/public
networks:
Expand Down
Loading

0 comments on commit 28e8245

Please sign in to comment.