Sacha VAUDEY 57f5807876
Some checks failed
Build and Test / Classic Build (pull_request) Failing after 2m19s
Build and Test / Docker Build (pull_request) Has been skipped
optimize archi
2025-09-14 12:54:18 +02:00

79 lines
2.0 KiB
YAML

name: Build and Test
run-name: Website build validation
on:
push:
branches: [main, dev]
pull_request:
branches: [main, dev]
jobs:
build-classic:
runs-on: ubuntu-latest
name: Classic Build
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
- uses: pnpm/action-setup@v4
with:
version: 8
- name: Install and build
run: |
cd banquise-website
pnpm install --frozen-lockfile
pnpm build
- name: Lint check
run: |
cd banquise-website
pnpm lint
build-docker:
runs-on: ubuntu-latest
name: Docker Build
needs: build-classic
steps:
- uses: actions/checkout@v4
- uses: docker/setup-buildx-action@v3
- name: Create Dockerfile if missing
run: |
cd banquise-website
if [ ! -f "Dockerfile" ]; then
cat > Dockerfile << 'EOF'
FROM node:20-alpine AS builder
RUN npm install -g pnpm
WORKDIR /app
COPY package.json pnpm-lock.yaml ./
RUN pnpm install --frozen-lockfile
COPY . .
RUN pnpm build
FROM node:20-alpine AS runner
RUN npm install -g pnpm
WORKDIR /app
COPY package.json pnpm-lock.yaml ./
RUN pnpm install --frozen-lockfile --prod
COPY --from=builder /app/.next ./.next
COPY --from=builder /app/public ./public
EXPOSE 3000
CMD ["pnpm", "start"]
EOF
fi
- name: Build and test Docker image
run: |
cd banquise-website
docker build -t banquise-website:test .
docker run -d --name test-container -p 3000:3000 banquise-website:test
sleep 5
docker ps | grep test-container
docker stop test-container
docker rm test-container