diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..fcbb9f85 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,60 @@ +name: Publish Release + +on: + push: + tags: + - '*.*' + +jobs: + release: + name: Publish Release + runs-on: ubuntu-latest + + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + + - name: Publish Release + uses: leomotors/auto-publish-release@main + with: + githubToken: ${{ secrets.GITHUB_TOKEN }} + title: 'programming.in.th' + tag: ${{ github.ref_name }} + + image: + name: Docker Image + runs-on: ubuntu-latest + + permissions: + id-token: write + packages: write + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Log in to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - uses: winterjung/split@v2 + id: version + with: + msg: ${{ github.ref_name }} + separator: '.' + + - name: Build Docker image + uses: docker/build-push-action@v6 + with: + context: . + file: Dockerfile + push: true + tags: ghcr.io/programming-in-th/programming.in.th:${{ github.ref_name }},ghcr.io/programming-in-th/programming.in.th:v${{ steps.version.outputs._0 }},ghcr.io/programming-in-th/programming.in.th:latest + platforms: linux/amd64,linux/arm64 + cache-from: type=gha + cache-to: type=gha,mode=max diff --git a/Dockerfile b/Dockerfile index 4708fb0c..c8f0328a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,20 +4,20 @@ FROM node:20-alpine AS base -ENV DOCKER_BUILD=1 -ENV NEXT_PUBLIC_REALTIME_URL=https://rtss.crackncode.org -ENV NEXT_PUBLIC_AWS_URL=https://prginth01.sgp1.cdn.digitaloceanspaces.com +ENV DOCKER_BUILD 1 +ENV NEXT_PUBLIC_REALTIME_URL https://rtss.crackncode.org +ENV NEXT_PUBLIC_AWS_URL https://prginth01.sgp1.cdn.digitaloceanspaces.com -ENV GITHUB_ID=mockvalue -ENV GITHUB_SECRET=mockvalue -ENV GOOGLE_CLIENT_ID=mockvalue -ENV GOOGLE_CLIENT_SECRET=mockvalue +ENV GITHUB_ID mockvalue +ENV GITHUB_SECRET mockvalue +ENV GOOGLE_CLIENT_ID mockvalue +ENV GOOGLE_CLIENT_SECRET mockvalue -ENV BUCKET_NAME=mockvalue -ENV BUCKET_KEY_ID=mockvalue -ENV BUCKET_KEY_SECRET=mockvalue -ENV BUCKET_ENDPOINT=mockvalue -ENV BUCKET_REGION=mockvalue +ENV BUCKET_NAME mockvalue +ENV BUCKET_KEY_ID mockvalue +ENV BUCKET_KEY_SECRET mockvalue +ENV BUCKET_ENDPOINT mockvalue +ENV BUCKET_REGION mockvalue # ? ------------------------- # ? Builder: Build production Next.js application to .next @@ -53,10 +53,10 @@ FROM base AS runner WORKDIR /app -LABEL name="programming.in.th" +LABEL name "programming.in.th" USER node -ENV NODE_ENV=production +ENV NODE_ENV production COPY package.json ./ @@ -66,8 +66,8 @@ COPY --chown=node:node --from=builder /app/.next/standalone ./ COPY --chown=node:node --from=builder /app/.next/static ./.next/static COPY --chown=node:node --from=builder /app/public ./public -ENV PORT=3000 -ENV HOST=0.0.0.0 +ENV PORT 3000 +ENV HOST 0.0.0.0 EXPOSE 3000 CMD ["node", "server.js"]