Skip to content

Commit

Permalink
Migration用のdocker imageを作る (#861)
Browse files Browse the repository at this point in the history
* wip

* add openssl

* mmm....

* rename
  • Loading branch information
SnO2WMaN authored Dec 5, 2023
1 parent 95f93d9 commit 3b0adb2
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 0 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/docker-api-postgres-migration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Docker Image for Postgres Migration

on:
push:
branches:
- main
paths:
- "prisma/migrations/**"
pull_request:
merge_group:

jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: hadolint/[email protected]
with:
dockerfile: Dockerfile.migration

- uses: docker/setup-buildx-action@v2
- uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- run: echo "LATEST_MIGRATION_NAME=$(ls -1 --ignore migration_lock.toml --reverse | head -n 1)" >> $GITHUB_ENV
- uses: docker/build-push-action@v4
with:
cache-from: type=gha
cache-to: type=gha,mode=max
context: .
file: Dockerfile.migration
push: ${{ github.event_name == 'push' }}
tags: ghcr.io/${{ github.repository_owner }}/api-postgres-migration:${{ env.LATEST_MIGRATION_NAME }}
21 changes: 21 additions & 0 deletions Dockerfile.migration
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
FROM node:20.8.1-slim@sha256:4fa1430cd19507875e65896fdf3176fc1674bc5bbf51b5f750fa30484885c18d
WORKDIR /app

# install OpenSSL
RUN apt-get update \
&& apt-get install -y --no-install-recommends openssl=3.0.11-1~deb12u1 \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

## install tini
ADD https://github.com/krallin/tini/releases/download/v0.19.0/tini /bin/tini
RUN chmod +x /bin/tini

## install all node.js dependencies
COPY package.json package-lock.json .npmrc ./
RUN npm ci

COPY ./prisma ./prisma

ENTRYPOINT ["tini", "--"]
CMD ["./node_modules/.bin/prisma", "migrate", "deploy"]

0 comments on commit 3b0adb2

Please sign in to comment.