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

add docker files #45

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
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
5 changes: 5 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules
npm-debug.log
docker-compose.yml
.DS_Store
.git
54 changes: 54 additions & 0 deletions .github/workflows/docker-image-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Build & Publish Docker Image

on:
push:
branches:
- main
pull_request:
branches:
- main

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/tbd-developer-pfi-exemplar

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
target: ${{ matrix.target }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
19 changes: 19 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Use the official Node.js image as the base image
FROM node:lts

# Set the working directory inside the container
WORKDIR /home/node/app

# Copy package.json and package-lock.json to the working directory
COPY --chown=node:node . /home/node/app/

# Install the application dependencies
RUN npm i

# Download and install dbmate
RUN curl -fsSL https://github.com/amacneil/dbmate/releases/download/v1.12.1/dbmate-linux-amd64 -o dbmate \
&& chmod +x dbmate \
&& mv dbmate /usr/local/bin

EXPOSE 9000
CMD [ "npm", "run", "server" ]
39 changes: 39 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
version: "3.8"

services:
postgresdb:
image: postgres:latest
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: tbd
POSTGRES_DB: mockpfi
ports:
- "5432:5432"
healthcheck:
test: ["CMD-SHELL", "postgres", "--health-cmd", "pg_isready"]
interval: 2s
timeout: 1s
retries: 5

pfi-app:
build:
context: .
dockerfile: Dockerfile
ports:
- "9000:9000"
environment:
NODE_ENV: production
# environment info
ENV: production
LOG_LEVEL: info
HOST: localhost
PORT: 9000

# DB info
SEC_DB_HOST: localhost
SEC_DB_PORT: 5432
SEC_DB_USER: postgres
SEC_DB_PASSWORD: tbd
SEC_DB_NAME: mockpfi
depends_on:
- postgresdb
8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@
"lint:fix": "eslint . --ext .ts --fix",
"seed-offerings": "npm run _start -- dist/seed-offerings.js",
"server": "npm run _start -- dist/main.js",
"test": "npm run example-create-issuer && npm run seed-offerings && npm run example-create-customer && npm run example-issue-credential && npm run example-e2e-exchange"
"try": "npm run _debug -- dist/client-test.js",
"docker:up": "docker-compose up -d",
"docker:down": "docker-compose down",
"docker:logs": "docker-compose logs -f",
"docker:build": "docker-compose build",
"test": "npm run example-create-issuer && npm run seed-offerings && npm run example-create-customer && npm run example-issue-credential && npm run example-e2e-exchange",
"docker:down-wipe": "docker-compose down -v"
}
}
Loading