Skip to content

Commit

Permalink
chore:add docker
Browse files Browse the repository at this point in the history
  • Loading branch information
hackycy committed May 15, 2021
1 parent 12419f8 commit b918553
Show file tree
Hide file tree
Showing 7 changed files with 177 additions and 1 deletion.
42 changes: 42 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# compiled output
/dist
/node_modules
package-lock.json

# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# OS
.DS_Store

# Tests
/coverage
/.nyc_output

# IDEs and editors
/.idea
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace

# IDE - VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json

# Code
src/config/config.development.*
docs/*
sql/*
test/*
README.md
34 changes: 34 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
name: Bug report(报告问题)
about: Create a report to help us improve
---
<!--
注意:为更好的解决你的问题,请参考模板提供完整信息,准确描述问题,信息不全的 issue 将被关闭。
Note: In order to better solve your problem, please refer to the template to provide complete information, accurately describe the problem, and the incomplete information issue will be closed.
-->


## Bug report(问题描述)

#### Steps to reproduce(问题复现步骤)
<!--
1. [xxx]
2. [xxx]
3. [xxxx]
-->

#### Screenshot or Gif(截图或动态图)


#### Link to minimal reproduction(最小可在线还原demo)

<!--
Please only use Codepen, JSFiddle, CodeSandbox or a github repo
-->

#### Other relevant information(格外信息)
- Your OS:
- Node.js version:
- Mysql version:
- Redis version:
7 changes: 7 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
name: Feature Request(新功能建议)
about: Suggest an idea for this project
---

## Feature request(新功能建议)

33 changes: 33 additions & 0 deletions .github/workflows/build-rc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Build RC Image

on:
create:
tags:
- '*'

jobs:
docker:
runs-on: ubuntu-latest
steps:
-
name: Set up QEMU
uses: docker/setup-qemu-action@v1
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
-
name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Build and push
id: docker_build
uses: docker/build-push-action@v2
with:
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/sfnestadmin:rc
-
name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
33 changes: 33 additions & 0 deletions .github/workflows/build-stable.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Build Stable Image

on:
push:
branches:
- 'main'

jobs:
docker:
runs-on: ubuntu-latest
steps:
-
name: Set up QEMU
uses: docker/setup-qemu-action@v1
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
-
name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Build and push
id: docker_build
uses: docker/build-push-action@v2
with:
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/sfnestadmin:stable
-
name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
27 changes: 27 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
FROM node:lts-alpine as builder
WORKDIR /sf-nest-admin

# install pm2
RUN npm install pm2 -g

# set timezone
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
RUN echo 'Asia/Shanghai' > /etc/timezone

# RUN npm set registry https://registry.npm.taobao.org
# cache step
COPY package.json /sf-nest-admin/package.json
RUN npm install
# build
COPY ./ /sf-nest-admin
RUN npm run build
# clean dev dep
RUN rm -rf node_modules && rm package-lock.json
RUN npm install --production

ENV NODE_ENV production

# bootstrap set port
EXPOSE 7001

CMD ["npm", "run", "start:prod"]
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"start": "cross-env NODE_ENV=development nest start",
"dev": "cross-env NODE_ENV=development nest start --watch",
"start:debug": "cross-env NODE_ENV=development nest start --debug --watch",
"start:prod": "node dist/main",
"start:prod": "pm2-runtime dist/main.js",
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
"test": "jest",
"test:watch": "jest --watch",
Expand Down

0 comments on commit b918553

Please sign in to comment.