Skip to content

Commit f493fd5

Browse files
committed
✨ Create docker builds
1 parent 974be92 commit f493fd5

4 files changed

Lines changed: 88 additions & 0 deletions

File tree

‎.dockerignore‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
*
2+
.*
3+
!index.js
4+
!lib/*.js
5+
!package*.json

‎.gitlab-ci.yml‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
cache:
2+
key: ${CI_COMMIT_REF_SLUG}
3+
paths:
4+
- node_modules/
5+
6+
stages:
7+
- test
8+
- deploy
9+
10+
test:
11+
image: node:lts
12+
stage: test
13+
before_script:
14+
- npm ci
15+
script:
16+
- npm test
17+
18+
build:
19+
image: docker:latest
20+
stage: deploy
21+
services:
22+
- docker:dind
23+
variables:
24+
DOCKER_DRIVER: overlay
25+
script:
26+
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
27+
- docker build --pull --label "git-ref=$CI_COMMIT_SHORT_SHA" --label "build-date=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" -t "${CI_REGISTRY_IMAGE}:latest" .
28+
- docker tag "${CI_REGISTRY_IMAGE}:latest" "${CI_REGISTRY_IMAGE}:$CI_COMMIT_SHORT_SHA" && docker push "${CI_REGISTRY_IMAGE}:$CI_COMMIT_SHORT_SHA"
29+
- docker push "${CI_REGISTRY_IMAGE}:latest"
30+
only:
31+
- master

‎Dockerfile‎

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
FROM node:lts-alpine
2+
LABEL name="wei/pull" maintainer="Wei He <docker@weispot.com>"
3+
4+
ENV \
5+
NODE_ENV=production \
6+
PORT=3000 \
7+
LOG_FORMAT=short \
8+
LOG_LEVEL=info \
9+
PULL_INTERVAL=1800 \
10+
WEBHOOK_PATH=/webhook \
11+
####################
12+
### Required ###
13+
####################
14+
APP_ID= \
15+
WEBHOOK_SECRET= \
16+
PRIVATE_KEY= \
17+
####################
18+
### Optional ###
19+
####################
20+
#CLIENT_ID= \
21+
#CLIENT_SECRET= \
22+
#SENTRY_DSN= \
23+
#SYSLOG_UDP_HOST= \
24+
#SYSLOG_UDP_PORT= \
25+
#GHE_HOST= \
26+
#IGNORED_ACCOUNTS= \
27+
#DISABLE_STATS= \
28+
_=
29+
30+
WORKDIR /home/node
31+
COPY package*.json ./
32+
RUN \
33+
apk add --no-cache --virtual build-dependencies build-base gcc wget git && \
34+
apk add --no-cache python && \
35+
npm ci --production && \
36+
apk del build-dependencies && \
37+
:
38+
39+
COPY . .
40+
41+
EXPOSE 3000
42+
CMD ["npm", "start"]

‎docker-compose.yml‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
version: "3"
2+
services:
3+
pull:
4+
build: ./
5+
volumes:
6+
- ./pk.pem:/home/node/pk.pem:ro
7+
env_file:
8+
- ./.env
9+
ports:
10+
- 3000:3000

0 commit comments

Comments
 (0)