From 2f21fddf1d52089266e1ab01a00d7fd70f88b485 Mon Sep 17 00:00:00 2001 From: Cma Date: Mon, 18 Nov 2024 23:02:28 +0900 Subject: [PATCH] docker setup --- .github/workflows/docker-build.yml | 52 ++++++++++++++++++++++++++++++ Dockerfile | 27 ++++++++++++++++ docker-compose.yaml | 13 ++++++++ 3 files changed, 92 insertions(+) create mode 100644 .github/workflows/docker-build.yml create mode 100644 Dockerfile create mode 100644 docker-compose.yaml diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml new file mode 100644 index 0000000..ed9f0e7 --- /dev/null +++ b/.github/workflows/docker-build.yml @@ -0,0 +1,52 @@ +name: DockerBuild +on: + push: + branches: [main] + +permissions: + id-token: write + contents: read + attestations: write + packages: write + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + build: + runs-on: ubuntu-latest + steps: + - + name: Checkout repository + uses: actions/checkout@v4 + - + name: Login to registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ github.token }} + - + name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + - + name: Build and push + id: push + uses: docker/build-push-action@v6 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + target: app + - + name: Generate artifact attestation + uses: actions/attest-build-provenance@v1 + with: + subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}} + subject-digest: ${{ steps.push.outputs.digest }} + push-to-registry: true diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..2aff272 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,27 @@ +FROM node:18 as base + +FROM base as build + +COPY ./app /remix/app +COPY ./package.json /remix/package.json +COPY ./package-lock.json /remix/package-lock.json +COPY ./postcss.config.js /remix/postcss.config.js +COPY ./tailwind.config.ts /remix/tailwind.config.ts +COPY ./tsconfig.json /remix/tsconfig.json +COPY ./vite.config.ts /remix/vite.config.ts + +WORKDIR /remix + +RUN npm ci && npm run build + +FROM base as app + +COPY --from=build /remix/build /app/build +COPY --from=build /remix/node_modules /app/node_modules +COPY --from=build /remix/package.json /app/package.json +COPY ./public /app/public +COPY ./.env /app/.env + +WORKDIR /app + +CMD [ "npm", "start" ] \ No newline at end of file diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..5405654 --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,13 @@ +version: '3' +services: + app: + build: + context: . + dockerfile: Dockerfile + target: app + ports: + - 13000:3000 + environment: + - DISCORD_USERNAME=受付PC + - DISCORD_WEBHOOK=https://discord.com/api/webhooks/669136267790909480/JckNafw2-d_RPfhNAYkc5rIc1wqkcOhLSdP3sn9miWTFLX0vZ7EBPyRxTgJvTbkhE87X + - DISCORD_MENTION=<@&794200015416983582> \ No newline at end of file