Skip to content

Commit

Permalink
feat: dockerize (#53)
Browse files Browse the repository at this point in the history
  • Loading branch information
naftis authored Sep 26, 2023
1 parent 4610976 commit 8b590aa
Show file tree
Hide file tree
Showing 8 changed files with 81 additions and 45 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/publish-to-dockerhub.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Publish image to Dockerhub

on:
push:
branches:
- master
- develop
- main
workflow_dispatch:
inputs:
branch_name:
description: Branch to build from
default: develop
required: true
jobs:
push:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
if: github.event_name == 'workflow_dispatch'
with:
ref: '${{ github.event.inputs.branch_name }}'
- uses: actions/checkout@v2
if: github.event_name == 'push'
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Push image
env:
DOCKERHUB_ACCOUNT: ${{ secrets.DOCKERHUB_ACCOUNT }}
DOCKERHUB_REPO: ${{ secrets.DOCKERHUB_REPO }}
run: |
export VERSION=`git rev-parse --short=7 HEAD`
echo "Publishing a Docker image with a tag $VERSION"
docker-compose build && docker-compose push && unset VERSION
15 changes: 15 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM node:20.7.0-alpine3.17
WORKDIR /usr/src/app

# Override the base log level (info).
ENV NPM_CONFIG_LOGLEVEL warn

COPY package.json package.json
COPY package-lock.json package-lock.json
COPY tsconfig.base.json tsconfig.base.json
COPY packages packages
RUN npm install --omit=dev

EXPOSE 1660

CMD ["npm", "start"]
7 changes: 7 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: "3.8"

services:
dci-crvs-api:
image: opencrvs/dci-crvs-api:${VERSION:-latest}
build: .
restart: unless-stopped
47 changes: 12 additions & 35 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
],
"scripts": {
"start": "npm start --workspace=dci-api",
"dev": "npm run dev --workspace=dci-api",
"test": "npm run test --workspaces",
"test:watch": "npm run test:watch --workspaces"
},
Expand Down
11 changes: 6 additions & 5 deletions packages/dci-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"main": "src/index.ts",
"license": "MIT",
"scripts": {
"start": "nodemon --watch ../../packages --exec ts-node src/index.ts",
"start": "NODE_ENV=production ts-node src/index.ts",
"dev": "nodemon --watch ../../packages --exec ts-node src/index.ts",
"test": "node --require ts-node/register --test src/**/*.test.ts",
"test:watch": "node --require ts-node/register --test --watch src/**/*.test.ts",
"generate-openapi-types": "openapi-typescript https://raw.githubusercontent.com/spdci/standards/draft/release/yaml/registry_core_api_v1.0.0.yaml -o ./src/registry-core-api.d.ts && npx prettier --write ./src/registry-core-api.d.ts"
Expand All @@ -14,19 +15,19 @@
"@hapi/boom": "^10.0.1",
"@hapi/h2o2": "^10.0.4",
"@hapi/hapi": "^21.3.2",
"@types/lodash": "^4.14.197",
"@types/node": "^20.5.3",
"hapi-pino": "^12.1.0",
"lodash": "^4.17.21",
"ts-node": "^10.9.1",
"typescript": "^5.1.6",
"zod": "^3.22.2",
"zod-validation-error": "^1.5.0"
},
"devDependencies": {
"@types/lodash": "^4.14.197",
"@types/node": "^20.5.3",
"msw": "0.0.0-fetch.rc-19",
"nodemon": "^3.0.1",
"openapi-typescript": "^6.5.3",
"pino-pretty": "^10.2.0",
"ts-node": "^10.9.1"
"pino-pretty": "^10.2.0"
}
}
4 changes: 1 addition & 3 deletions packages/dci-opencrvs-bridge/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@
"main": "src/index.ts",
"license": "ISC",
"dependencies": {
"lodash": "^4.17.21"
},
"devDependencies": {
"@types/lodash": "^4.14.197",
"lodash": "^4.17.21",
"typescript": "^5.2.2"
}
}
4 changes: 2 additions & 2 deletions packages/opencrvs-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"generate-gateway-types": "graphql-codegen --config codegen.yml && npx prettier --write src/gateway.ts"
},
"dependencies": {
"@types/jsonwebtoken": "^9.0.3",
"graphql": "^16.8.0",
"graphql-tag": "^2.12.6",
"jsonwebtoken": "^9.0.2",
Expand All @@ -18,7 +19,6 @@
"@graphql-codegen/cli": "^5.0.0",
"@graphql-codegen/introspection": "^4.0.0",
"@graphql-codegen/typescript": "^4.0.0",
"@graphql-codegen/typescript-operations": "^4.0.0",
"@types/jsonwebtoken": "^9.0.3"
"@graphql-codegen/typescript-operations": "^4.0.0"
}
}

0 comments on commit 8b590aa

Please sign in to comment.