Skip to content

Commit

Permalink
Build docker image (#109)
Browse files Browse the repository at this point in the history
  • Loading branch information
Asing1001 committed Feb 4, 2023
1 parent 392ac48 commit e572765
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 5 deletions.
46 changes: 41 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ on:

env:
NODE_VERSION: 12.22.1
PROJECT_ID: movierater-1492834745733

permissions:
id-token: write

jobs:
build:
Expand Down Expand Up @@ -39,13 +43,45 @@ jobs:
run: docker-compose up -d

- name: Wait for services to start
run: sleep 15
run: sleep 5

- name: Run tests
run: yarn test

- name: Generate sitemap
run: yarn sitemap

- name: Stop services
run: docker-compose down
run: docker-compose down

publish:
needs: build
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Build Docker image
if: github.ref == 'refs/heads/master'
run: |
docker build -t asia-east1-docker.pkg.dev/${{ env.PROJECT_ID }}/movierater/movierater .
- id: 'auth'
name: 'Authenticate to GCP'
uses: 'google-github-actions/[email protected]'
if: github.ref == 'refs/heads/master'
with:
create_credentials_file: 'true'
workload_identity_provider: ${{ secrets.WORKLOAD_IDENTITY_PROVIDER }}
service_account: ${{ secrets.SERVICE_ACCOUNT }}

- id: 'gcloud'
name: 'gcloud login'
if: github.ref == 'refs/heads/master'
run: |-
gcloud auth login --brief --cred-file="${{ steps.auth.outputs.credentials_file_path }}"
gcloud config set project ${{ env.PROJECT_ID }}
gcloud services list
- name: Push Docker image to Artifact Registry
if: github.ref == 'refs/heads/master'
run: |
docker push asia-east1-docker.pkg.dev/${{ env.PROJECT_ID }}/movierater/movierater
20 changes: 20 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Use the official Node.js image
FROM node:12.22.1

# Set the working directory
WORKDIR /app

# Copy package.json and yarn.lock to the working directory
COPY package.json yarn.lock ./

# Install dependencies
RUN yarn

# Copy the rest of the application code to the working directory
COPY . .

# Run the build step
RUN yarn build

# Set the command to run the application when the container starts
CMD ["yarn", "start"]

0 comments on commit e572765

Please sign in to comment.