fix: mount /apps and docker socket in PR workflow build-and-deploy-ci job #41
@@ -8,6 +8,7 @@ on:
|
|||||||
- "Dockerfile.ci-base"
|
- "Dockerfile.ci-base"
|
||||||
- "package.json"
|
- "package.json"
|
||||||
- "bun.lock"
|
- "bun.lock"
|
||||||
|
- "package-lock.json"
|
||||||
- ".gitea/workflows/build-ci-images.yml"
|
- ".gitea/workflows/build-ci-images.yml"
|
||||||
schedule:
|
schedule:
|
||||||
# Weekly rebuild to get latest Playwright/Bun versions
|
# Weekly rebuild to get latest Playwright/Bun versions
|
||||||
|
|||||||
@@ -23,13 +23,13 @@ jobs:
|
|||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: bun install --retry 3
|
run: npm ci --legacy-peer-deps
|
||||||
|
|
||||||
- name: Generate Prisma client
|
- name: Generate Prisma client
|
||||||
run: bun x prisma generate
|
run: npx prisma generate
|
||||||
|
|
||||||
- name: Run unit tests
|
- name: Run unit tests
|
||||||
run: bun test src/__tests__/unit/ src/__tests__/*.test.tsx src/__tests__/auth-simple.test.ts
|
run: npm test
|
||||||
|
|
||||||
build-and-deploy-ci:
|
build-and-deploy-ci:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
@@ -45,10 +45,10 @@ jobs:
|
|||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: bun install --retry 3
|
run: npm ci --legacy-peer-deps
|
||||||
|
|
||||||
- name: Generate Prisma client
|
- name: Generate Prisma client
|
||||||
run: bun x prisma generate
|
run: npx prisma generate
|
||||||
env:
|
env:
|
||||||
DATABASE_URL: postgresql://user:pass@localhost:5432/dummy
|
DATABASE_URL: postgresql://user:pass@localhost:5432/dummy
|
||||||
|
|
||||||
@@ -93,7 +93,7 @@ jobs:
|
|||||||
exit 1
|
exit 1
|
||||||
|
|
||||||
- name: Run acceptance tests
|
- name: Run acceptance tests
|
||||||
run: DATABASE_URL="${{ secrets.CI_DATABASE_URL }}" bun test:acceptance
|
run: DATABASE_URL="${{ secrets.CI_DATABASE_URL }}" npx playwright test e2e/
|
||||||
env:
|
env:
|
||||||
CI: true
|
CI: true
|
||||||
|
|
||||||
|
|||||||
@@ -73,10 +73,10 @@ jobs:
|
|||||||
echo "Bumping version: $BUMP"
|
echo "Bumping version: $BUMP"
|
||||||
|
|
||||||
# Run the bump script
|
# Run the bump script
|
||||||
bun run scripts/bump-version.js "$BUMP" --yes
|
node scripts/bump-version.js "$BUMP" --yes
|
||||||
|
|
||||||
# Get new version
|
# Get new version
|
||||||
NEW_VERSION=$(bun -e "console.log(require('./package.json').version)")
|
NEW_VERSION=$(node -e "console.log(require('./package.json').version)")
|
||||||
echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
|
echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
|
||||||
echo "New version: $NEW_VERSION"
|
echo "New version: $NEW_VERSION"
|
||||||
|
|
||||||
@@ -121,8 +121,9 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
docker run --rm \
|
docker run --rm \
|
||||||
-e DATABASE_URL="postgresql://user:pass@localhost:5432/dummy" \
|
-e DATABASE_URL="postgresql://user:pass@localhost:5432/dummy" \
|
||||||
|
-e NODE_ENV=test \
|
||||||
${{ env.IMAGE_NAME }}-test:${{ steps.version.outputs.new_version }} \
|
${{ env.IMAGE_NAME }}-test:${{ steps.version.outputs.new_version }} \
|
||||||
bun test 'src/__tests__/unit/**' 'src/__tests__/*.test.tsx' 'src/__tests__/auth-simple.test.ts'
|
npm test
|
||||||
|
|
||||||
- name: Build production image
|
- name: Build production image
|
||||||
if: steps.commit.outputs.committed == 'true'
|
if: steps.commit.outputs.committed == 'true'
|
||||||
|
|||||||
+11
-11
@@ -4,7 +4,7 @@
|
|||||||
FROM oven/bun:alpine AS builder
|
FROM oven/bun:alpine AS builder
|
||||||
|
|
||||||
# Install dependencies (needed for native modules)
|
# Install dependencies (needed for native modules)
|
||||||
RUN apk add --no-cache python3 make g++
|
RUN apk add --no-cache python3 make g++ nodejs npm
|
||||||
|
|
||||||
# Set working directory
|
# Set working directory
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
@@ -13,14 +13,14 @@ WORKDIR /app
|
|||||||
COPY package*.json ./
|
COPY package*.json ./
|
||||||
|
|
||||||
# Install dependencies (including dev dependencies for building)
|
# Install dependencies (including dev dependencies for building)
|
||||||
RUN bun install --retry 3
|
RUN npm ci --legacy-peer-deps
|
||||||
|
|
||||||
# Copy source code
|
# Copy source code
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
# Generate Prisma client (with dummy PostgreSQL DATABASE_URL for build-time generation)
|
# Generate Prisma client (with dummy PostgreSQL DATABASE_URL for build-time generation)
|
||||||
# Note: A dummy URL is used since the real database is not available during build
|
# Note: A dummy URL is used since the real database is not available during build
|
||||||
RUN DATABASE_PROVIDER=postgresql DATABASE_URL="postgresql://user:pass@localhost:5432/dummy" bun x prisma generate
|
RUN DATABASE_PROVIDER=postgresql DATABASE_URL="postgresql://user:pass@localhost:5432/dummy" npx prisma generate
|
||||||
|
|
||||||
# Build the application (with dummy DATABASE_URL for static page generation and git commit)
|
# Build the application (with dummy DATABASE_URL for static page generation and git commit)
|
||||||
ARG GIT_COMMIT=unknown
|
ARG GIT_COMMIT=unknown
|
||||||
@@ -30,7 +30,7 @@ RUN DATABASE_PROVIDER=postgresql DATABASE_URL="postgresql://user:pass@localhost:
|
|||||||
FROM oven/bun:alpine AS test-runner
|
FROM oven/bun:alpine AS test-runner
|
||||||
|
|
||||||
# Install dependencies
|
# Install dependencies
|
||||||
RUN apk add --no-cache python3 make g++ git
|
RUN apk add --no-cache python3 make g++ git nodejs npm
|
||||||
|
|
||||||
# Set working directory
|
# Set working directory
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
@@ -39,19 +39,19 @@ WORKDIR /app
|
|||||||
COPY package*.json ./
|
COPY package*.json ./
|
||||||
|
|
||||||
# Install ALL dependencies (including dev dependencies for testing)
|
# Install ALL dependencies (including dev dependencies for testing)
|
||||||
RUN bun install --retry 3
|
RUN npm ci --legacy-peer-deps
|
||||||
|
|
||||||
# Copy source code
|
# Copy source code
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
# Generate Prisma client
|
# Generate Prisma client
|
||||||
RUN DATABASE_PROVIDER=postgresql DATABASE_URL="postgresql://user:pass@localhost:5432/dummy" bun x prisma generate
|
RUN DATABASE_PROVIDER=postgresql DATABASE_URL="postgresql://user:pass@localhost:5432/dummy" npx prisma generate
|
||||||
|
|
||||||
# Stage 3: Production runner
|
# Stage 3: Production runner
|
||||||
FROM oven/bun:alpine AS runner
|
FROM oven/bun:alpine AS runner
|
||||||
|
|
||||||
# Install dumb-init for proper signal handling
|
# Install dumb-init and npm for production install
|
||||||
RUN apk add --no-cache dumb-init
|
RUN apk add --no-cache dumb-init nodejs npm
|
||||||
|
|
||||||
# Create non-root user
|
# Create non-root user
|
||||||
RUN addgroup --system --gid 1001 euchre && \
|
RUN addgroup --system --gid 1001 euchre && \
|
||||||
@@ -64,15 +64,15 @@ WORKDIR /app
|
|||||||
COPY --from=builder --chown=euchre:euchre /app/.next ./.next
|
COPY --from=builder --chown=euchre:euchre /app/.next ./.next
|
||||||
COPY --from=builder --chown=euchre:euchre /app/public ./public
|
COPY --from=builder --chown=euchre:euchre /app/public ./public
|
||||||
COPY --from=builder --chown=euchre:euchre /app/package.json ./package.json
|
COPY --from=builder --chown=euchre:euchre /app/package.json ./package.json
|
||||||
COPY --from=builder --chown=euchre:euchre /app/bun.lock ./bun.lock
|
COPY --from=builder --chown=euchre:euchre /app/package-lock.json ./package-lock.json
|
||||||
COPY --from=builder --chown=euchre:euchre /app/prisma ./prisma
|
COPY --from=builder --chown=euchre:euchre /app/prisma ./prisma
|
||||||
|
|
||||||
# Install only production dependencies
|
# Install only production dependencies
|
||||||
RUN bun install --retry 3 --production
|
RUN npm ci --legacy-peer-deps --omit=dev
|
||||||
|
|
||||||
# Generate Prisma client
|
# Generate Prisma client
|
||||||
# Note: We need to set DATABASE_URL even for generation because prisma.config.ts requires it
|
# Note: We need to set DATABASE_URL even for generation because prisma.config.ts requires it
|
||||||
RUN DATABASE_PROVIDER=postgresql DATABASE_URL="postgresql://user:pass@localhost:5432/dummy" bun x prisma generate
|
RUN DATABASE_PROVIDER=postgresql DATABASE_URL="postgresql://user:pass@localhost:5432/dummy" npx prisma generate
|
||||||
|
|
||||||
# Switch to non-root user
|
# Switch to non-root user
|
||||||
USER euchre
|
USER euchre
|
||||||
|
|||||||
Generated
+10473
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user