Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass.muxi tech.xyz auth fix #29

Open
wants to merge 10 commits into
base: refactor-pass
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions .drone.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
kind: pipeline
type: docker
name: muxiauth/fe

trigger:
ref:
- refs/tags/release-* #触发器,当打入以release-为模板的新tags时开始执行。

clone:
depth: 1 #克隆当前文件

steps:
- name: build-assets
image: node #在node Docker 容器当中
environment: #环境变量
REACT_APP_VERSION: ${DRONE_TAG}
PUBLIC_URL: http://static.muxixyz.com/muxiauth/fe/ #create-my-app脚手架中的环境变量
commands: #执行
- yarn config set registry https://registry.npm.taobao.org
- yarn install
- yarn build
- name: upload-assets
image: node
environment:
AK:
from_secret: AK
SK:
from_secret: SK
commands:
- yarn global add qiniu-upload-tool --registry=https://registry.npm.taobao.org
- qiniu-upload push -z huad -p ./build -b ccnustatic -f muxiauth/fe -r yes
- rm -rf ./src
- rm -rf ./node_modules
- name: build-and-push-image # 构建 user 服务镜像
image: plugins/docker
volumes:
- name: dockersock # 挂载下面定义的Volumn
path: /var/run/docker.sock # 与宿主机用同一docker
settings: # plugins/docker用到的相关配置
username:
from_secret: docker_user # alicloud指定的docker hub的用户名(前面配置)
password:
from_secret: docker_password # alicloud指定的docker hub的密码(前面配置)
repo: registry-vpc.cn-hangzhou.aliyuncs.com/muxiauth/fe #要推送docker地址
registry: registry-vpc.cn-hangzhou.aliyuncs.com # 使用的docker hub地址
tags: ${DRONE_TAG}
volumes:
- name: dockersock
host:
path: /var/run/docker.sock
9 changes: 3 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,11 @@ RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
COPY . /usr/src/app

# Build static file
RUN npm install --registry=https://registry.npm.taobao.org
RUN npm run build

WORKDIR /usr/src/app/server

# Build server file
RUN npm install --registry=https://registry.npm.taobao.org
# Build server file 先换源
RUN yarn config set registry https://registry.npm.taobao.org/
RUN yarn install

# Bundle app source
EXPOSE 3000
Expand Down
5 changes: 5 additions & 0 deletions package-lock.json

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

8 changes: 5 additions & 3 deletions server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@ const Router = require("koa-router");
const userAgent = require("koa-useragent");
const path = require("path");
const swig = require("swig");
const bodyParser = require('koa-bodyparser');
const router = new Router();
const app = new Koa();

const templateRoot = path.join(__dirname, "../build");
const templateRoot = path.join(__dirname, "../build/");

app.use(userAgent);
app.use(bodyParser());

router.get("/", function(ctx, next) {
router.get(/^\/(.*)$/, function(ctx, next) {
ctx.cookies.set("landing", ctx.request.query.landing, {
httpOnly: false
});
Expand All @@ -20,7 +22,7 @@ router.get("/", function(ctx, next) {
});

router.get(/^\/static(?:\/|$)/, async ctx => {
let filepath = ctx.path;
let filepath = ctx.path.replace(/static\//,'');
await send(ctx, filepath, {
root: path.join(__dirname, "../build"),
maxage: 60 * 60 * 24 * 365
Expand Down
1 change: 1 addition & 0 deletions server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"dependencies": {
"koa": "^2.2.0",
"koa-router": "^7.2.0",
"koa-bodyparser": "^4.2.0",
"koa-send": "^4.1.0",
"koa-useragent": "^1.0.0",
"swig": "^1.4.2"
Expand Down
Loading