This commit is contained in:
Joey Zhou 2024-05-02 10:35:31 -07:00
Родитель 07ae70535b
Коммит 1e103db8fb
2 изменённых файлов: 50 добавлений и 14 удалений

28
.github/workflows/preview_deploy_gcp.yml поставляемый
Просмотреть файл

@ -16,19 +16,19 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v2
- uses: actions/setup-node@v4
with:
node-version: 20.12
- name: Install dependencies
run: npm ci
- name: Copy env var
run: cp .env-dist .env
- name: Setting up postgres
run: npm run db:migrate
env:
APP_ENV: cloudrun
DATABASE_URL: postgres://postgres@${{ env.DB_HOST }}:5432/blurts
PG_HOST: /cloudsql/${{ env.PROJECT_ID }}:${{env.REGION}}:blurts-server-pr
# - uses: actions/setup-node@v4
# with:
# node-version: 20.12
# - name: Install dependencies
# run: npm ci
# - name: Copy env var
# run: cp .env-dist .env
# - name: Setting up postgres
# run: npm run db:migrate
# env:
# APP_ENV: cloudrun
# DATABASE_URL: postgres://postgres@${{ env.DB_HOST }}:5432/blurts
# PG_HOST: /cloudsql/${{ env.PROJECT_ID }}:${{env.REGION}}:blurts-server-pr
- name: Setup Cloud SDK
uses: 'google-github-actions/auth@v2'
@ -44,7 +44,7 @@ jobs:
- name: Build and Push Container
run: |-
docker build -t ${{env.REGION}}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.SERVICE }}/${{ env.SERVICE }}:${{ env.TAG }} .
docker build -t ${{env.REGION}}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.SERVICE }}/${{ env.SERVICE }}:${{ env.TAG }} -f ./Dockerfile_with_migrate
docker push ${{env.REGION}}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.SERVICE }}/${{ env.SERVICE }}:${{ env.TAG }}
- name: Deploy to Cloud Run

36
Dockerfile_with_migrate Normal file
Просмотреть файл

@ -0,0 +1,36 @@
FROM node:20.12-alpine
RUN addgroup -g 10001 app && \
adduser -D -G app -h /app -u 10001 app
RUN rm -rf /tmp/*
# Install Python
ENV PYTHONUNBUFFERED=1
RUN apk add --update --no-cache python3 py3-pip && ln -sf python3 /usr/bin/python
WORKDIR /app
USER app
COPY package.json package.json
COPY package-lock.json package-lock.json
COPY --chown=app:app . /app
RUN npm ci --audit=false && rm -rf ~app/.npm /tmp/*
COPY .env-dist ./.env
ARG NEXT_PUBLIC_GA4_DEBUG_MODE
ENV NEXT_PUBLIC_GA4_DEBUG_MODE=false
ARG S3_BUCKET
ENV S3_BUCKET=$S3_BUCKET
RUN GLEAN_PYTHON=python GLEAN_PIP=pip npm run build
RUN npm run db:migrate
ARG SENTRY_RELEASE
ENV SENTRY_RELEASE=$SENTRY_RELEASE
CMD ["npm", "start"]