Skip to content
This repository has been archived by the owner on Dec 12, 2024. It is now read-only.

Commit

Permalink
PR #9 - Deploy Calendar Service as Service
Browse files Browse the repository at this point in the history
* Create .Dockerfile for the Calendar Service
* Add GH Actions workflow to build and publish Docker iage

Move
  • Loading branch information
ALRubinger committed Nov 16, 2023
1 parent 3fc6c21 commit b7152d4
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 0 deletions.
20 changes: 20 additions & 0 deletions .Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Use an official Node runtime as a parent image
FROM node:20-alpine3.17

# Set the working directory in the container
WORKDIR /workspace/app

# Copy package.json and package-lock.json (if available)
COPY package*.json ./

# Install app dependencies
RUN npm install

# Bundle app source inside the Docker image
COPY . .

# Your app binds to port 3000 so you'll use the EXPOSE instruction to have it mapped by the docker daemon
EXPOSE 3000

# Define the command to run your app using CMD which defines your runtime
CMD [ "node", "app.js" ]
50 changes: 50 additions & 0 deletions .github/workflows/docker-image-publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Create and publish the Docker image

on:
push:
branches: ['main']
pull_request:
workflow_dispatch:

env:
REGISTRY: ghcr.io

jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

strategy:
fail-fast: false
matrix:
include:
- dockerfile: ./.Dockerfile
image: ghcr.io/tbd54566975/calendar-service

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Log in to the Container registry
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
with:
images: ${{ matrix.image }}

- name: Build and push Docker image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
context: .
file: .Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

0 comments on commit b7152d4

Please sign in to comment.