diff --git a/.github/workflows/cd.yaml b/.github/workflows/cd.yaml new file mode 100644 index 00000000..7e4b6259 --- /dev/null +++ b/.github/workflows/cd.yaml @@ -0,0 +1,41 @@ +name: Continuous Deployment +on: + push: + branches: [ main ] +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Docker login + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Build and push + uses: docker/build-push-action@v4 + with: + context: . + file: ./Dockerfile.prod + push: true + tags: 100xdevs/job-board-staging:${{ github.sha }} + + - name: Clone staging-ops repo, update, and push + env: + PAT: ${{ secrets.STAGING_OPS_PAT }} + run: | + git clone https://github.com/code100x/staging-ops.git + cd staging-ops + sed -i 's|image: 100xdevs/job-board-staging:.*|image: 100xdevs/job-board-staging:${{ github.sha }}|' job-board/deployment.yaml + git config user.name "GitHub Actions Bot" + git config user.email "actions@github.com" + git add job-board/deployment.yaml + git commit -m "Update job-board-staging image to ${{ github.sha }}" + git push https://${PAT}@github.com/code100x/staging-ops.git main \ No newline at end of file diff --git a/Dockerfile.prod b/Dockerfile.prod new file mode 100644 index 00000000..0000cd8e --- /dev/null +++ b/Dockerfile.prod @@ -0,0 +1,19 @@ + +FROM node:20-alpine AS build +ARG DATABASE_URL +WORKDIR /usr/src/app +COPY package*.json ./ +RUN npm install +COPY . . +RUN DATABASE_URL=$DATABASE_URL npx prisma generate +RUN DATABASE_URL=$DATABASE_URL npm run build + +FROM node:20-alpine AS production +WORKDIR /usr/src/app +COPY --from=build /usr/src/app/.next ./.next +COPY --from=build /usr/src/app/node_modules ./node_modules +COPY --from=build /usr/src/app/public ./public +COPY --from=build /usr/src/app/package.json ./package.json +CMD ["npm", "run", "start"] + +EXPOSE 3000 \ No newline at end of file diff --git a/prisma/migrations/20240915194739_init/migration.sql b/prisma/migrations/20240915194739_init/migration.sql new file mode 100644 index 00000000..0e7f2dbe --- /dev/null +++ b/prisma/migrations/20240915194739_init/migration.sql @@ -0,0 +1,15 @@ +/* + Warnings: + + - You are about to drop the column `location` on the `Job` table. All the data in the column will be lost. + - Added the required column `address` to the `Job` table without a default value. This is not possible if the table is not empty. + - Added the required column `city` to the `Job` table without a default value. This is not possible if the table is not empty. + +*/ +-- AlterTable +ALTER TABLE "Job" DROP COLUMN "location", +ADD COLUMN "address" TEXT NOT NULL, +ADD COLUMN "city" TEXT NOT NULL; + +-- DropEnum +DROP TYPE "JobLocations";