Skip to content

Commit 2e96bf2

Browse files
authored
Dockerfile and automatic build/testing (#949)
* Dockerfile and automatic build/testing * Bump Node engine version * Allow linting to fail * Allow testing to fail until tests are writen * Remove procfile, tag latest, fix entrypoint
1 parent b4e6df2 commit 2e96bf2

File tree

6 files changed

+82
-19
lines changed

6 files changed

+82
-19
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: ci
2+
3+
on:
4+
push:
5+
branches:
6+
- 'master'
7+
8+
jobs:
9+
docker:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Login to DockerHub
13+
uses: docker/login-action@v1
14+
with:
15+
registry: ghcr.io
16+
username: r-webdev
17+
password: ${{ secrets.GITHUB_TOKEN }}
18+
- name: Build and push
19+
id: docker_build
20+
uses: docker/build-push-action@v2
21+
with:
22+
push: true
23+
tags: ghcr.io/r-webdev/support-bot:stable,ghcr.io/r-webdev/support-bot:latest

.github/workflows/deploy.yml

Lines changed: 0 additions & 17 deletions
This file was deleted.

.github/workflows/test.yaml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: test
2+
3+
on:
4+
pull_request:
5+
6+
jobs:
7+
test:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Checkout
11+
uses: actions/checkout@v3
12+
13+
- name: Cache npm dependencies
14+
uses: actions/cache@v3
15+
env:
16+
cache-name: cache-npm
17+
with:
18+
path: node_modules
19+
key: ${{ env.cache-name }}-${{ hashFiles('**/yarn.lock') }}
20+
restore-keys: |
21+
${{ env.cache-name }}-${{ hashFiles('**/yarn.lock') }}
22+
${{ env.cache-name }}-
23+
24+
- name: Install dependencies
25+
run: yarn install --frozen-lockfile
26+
27+
# These are temporarily allowed to fail.
28+
# "Temporarily"
29+
- name: Lint
30+
run: npm run lint
31+
continue-on-error: true
32+
- name: Test
33+
run: npm run test
34+
continue-on-error: true

Dockerfile

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
FROM node:16.18.1-alpine AS deps
2+
3+
WORKDIR /app
4+
5+
COPY package.json ./
6+
COPY tsconfig.json ./
7+
COPY yarn.lock ./
8+
COPY src ./src
9+
10+
RUN yarn install --frozen-lockfile
11+
RUN npm run build
12+
13+
FROM node:16.18.1-alpine
14+
15+
WORKDIR /app
16+
17+
ENV NODE_ENV=production
18+
19+
COPY package.json ./
20+
COPY yarn.lock ./
21+
RUN yarn install --frozen-lockfile && rm -rf /usr/local/share/.cache
22+
COPY --from=deps /app/build .
23+
24+
CMD ["node","index.js"]

Procfile

Lines changed: 0 additions & 1 deletion
This file was deleted.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"main": "index.js",
66
"type": "module",
77
"engines": {
8-
"node": "16.15.0"
8+
"node": "16.18.1"
99
},
1010
"scripts": {
1111
"dev": "cross-env TS_NODE_FILES=true TS_NODE_PROJECT=\"./tsconfig.json\" nodemon -r dotenv/config -x node --experimental-specifier-resolution=node --loader ts-node/esm ./src/index.ts",

0 commit comments

Comments
 (0)