Skip to content

Commit

Permalink
Merge pull request #6 from nicbus/docker
Browse files Browse the repository at this point in the history
add docker image + build in CI
  • Loading branch information
grunch authored Dec 20, 2022
2 parents c2bfefa + d3adee9 commit 6a75de7
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
*

!/src/
!/LICENSE
!/package-lock.json
!/package.json
!/README.md
!/tsconfig.json

/src/version.ts
42 changes: 42 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: docker

on:
push:
tags:
- '*'

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

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

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

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

- name: Extract metadata (tags, labels) for Docker
uses: docker/metadata-action@v4
id: meta
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Build and push Docker image
uses: docker/build-push-action@v3
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
20 changes: 20 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM node:18-bullseye

RUN apt-get -y update \
&& apt-get -y install tini \
&& apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

WORKDIR "/srv"

COPY package.json package-lock.json tsconfig.json ./
COPY src ./src

RUN npm install
RUN npm run build

ENV NODE_ENV="production"

EXPOSE 3000/tcp
VOLUME ["/root/.npm", "/root/.rgb-proxy-server"]

CMD ["tini", "--", "npm", "run", "start"]
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"build": "tsc",
"lint": "eslint --ignore-path .gitignore . --ext .ts",
"lint:fix": "npm run lint -- --fix",
"pretest": "npm run version",
"test": "jest --verbose",
"version": "echo 'export const APP_VERSION = \"'$npm_package_version'\"' > src/version.ts"
},
Expand Down

0 comments on commit 6a75de7

Please sign in to comment.