Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: dbmigrate docker image #233

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .github/workflows/continuous-delivery.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ on:
paths:
- 'src/**'
- 'Dockerfile'
- 'Dockerfile.dbmigrate'
- '.github/workflows/continuous-delivery.yml'
- 'package.json'

Expand All @@ -34,3 +35,27 @@ jobs:
push: true
context: .
tags: ghcr.io/skyra-project/teryl:latest

PublishDbMigrate:
name: Publish Teryl's DB Migration image to container registries
runs-on: ubuntu-latest
steps:
- name: Checkout Project
uses: actions/checkout@v4
with:
submodules: true
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v3.3.0
- name: Login to GitHub Container Registry
uses: docker/login-action@v3.1.0
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Teryl Docker image
uses: docker/build-push-action@v5.3.0
with:
push: true
context: .
file: ./Dockerfile.dbmigrate
tags: ghcr.io/skyra-project/teryl-dbmigrate:latest
36 changes: 36 additions & 0 deletions Dockerfile.dbmigrate
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# ================ #
# Base Stage #
# ================ #

FROM node:20-alpine AS base

WORKDIR /usr/src/app

ENV YARN_DISABLE_GIT_HOOKS=1

COPY --chown=node:node yarn.lock .
COPY --chown=node:node package.json .
COPY --chown=node:node .yarnrc.yml .
COPY --chown=node:node .yarn/ .yarn/

# ================== #
# DBMigrate Stage #
# ================== #

FROM base AS dbmigrate

ENV NODE_ENV="development"

COPY --chown=node:node tsconfig.base.json .
COPY --chown=node:node prisma/ prisma/
COPY --chown=node:node src/ src/

RUN yarn install --immutable
RUN yarn run prisma:generate
RUN yarn run build

ENV NODE_ENV="production"

USER node

CMD [ "yarn", "run", "prisma:migrate" ]
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"dev": "yarn build && yarn start",
"watch": "tsc -b src -w",
"prisma:generate": "yarn prisma generate",
"prisma:migrate": "yarn prisma migrate deploy",
"clean": "rimraf dist/",
"start": "node --enable-source-maps dist/main.js",
"test": "vitest run",
Expand Down