Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
Y
yangpu
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
郭铭瑶
yangpu
Commits
0aae32c7
Commit
0aae32c7
authored
Nov 24, 2020
by
盛金强
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
t
parent
23479acd
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
126 additions
and
0 deletions
+126
-0
Dockerfile
Dockerfile
+5
-0
Jenkinsfile
Jenkinsfile
+38
-0
.gitkeep
deploy/.gitkeep
+0
-0
k8s.yaml
deploy/k8s.yaml
+63
-0
nginx.conf
nginx.conf
+20
-0
No files found.
Dockerfile
0 → 100644
View file @
0aae32c7
FROM
10.0.6.228:5000/node-nginx:8.12.0-slim
WORKDIR
/app
COPY
. /app/
RUN
npm config
set
proxy
=
http://10.0.6.228:3128
&&
npm
set
registry https://registry.npm.taobao.org
&&
npm
install
&&
npm run build:huangpu-sit
&&
cp
-r
dist/
*
/var/www/html
&&
cp
nginx.conf /etc/nginx/conf.d
&&
rm
-rf
/etc/nginx/sites-enabled
&&
rm
-rf
/app
Jenkinsfile
0 → 100644
View file @
0aae32c7
pipeline
{
agent
{
node
{
label
'nodejs'
}
}
environment
{
KUBECONFIG_CREDENTIAL_ID
=
'devops-kubeconfig'
REGISTRY
=
'10.0.6.228:5000'
DOCKERHUB_NAMESPACE
=
'house-manage-hp'
APP_NAME
=
'web-main'
NAMESPACE
=
'house-manage-hp'
}
stages
{
stage
(
'checkout scm'
)
{
steps
{
checkout
(
scm
)
}
}
stage
(
'build & push'
)
{
steps
{
container
(
'nodejs'
)
{
sh
'docker build -f Dockerfile -t $REGISTRY/$DOCKERHUB_NAMESPACE/$APP_NAME:$BUILD_NUMBER .'
sh
'docker push $REGISTRY/$DOCKERHUB_NAMESPACE/$APP_NAME:$BUILD_NUMBER'
}
}
}
stage
(
'deploy'
)
{
steps
{
kubernetesDeploy
(
configs:
'deploy/**'
,
enableConfigSubstitution:
true
,
kubeconfigId:
"$KUBECONFIG_CREDENTIAL_ID"
)
}
}
}
}
deploy/.gitkeep
0 → 100644
View file @
0aae32c7
deploy/k8s.yaml
0 → 100644
View file @
0aae32c7
---
apiVersion
:
extensions/v1beta1
kind
:
Deployment
metadata
:
labels
:
app
:
$APP_NAME
name
:
$APP_NAME
namespace
:
$NAMESPACE
spec
:
progressDeadlineSeconds
:
600
replicas
:
1
selector
:
matchLabels
:
app
:
$APP_NAME
template
:
metadata
:
labels
:
app
:
$APP_NAME
spec
:
containers
:
-
image
:
$REGISTRY/$DOCKERHUB_NAMESPACE/$APP_NAME:$BUILD_NUMBER
imagePullPolicy
:
Always
name
:
$APP_NAME
readinessProbe
:
httpGet
:
path
:
/
port
:
80
timeoutSeconds
:
10
failureThreshold
:
30
periodSeconds
:
5
ports
:
-
containerPort
:
80
protocol
:
TCP
resources
:
limits
:
cpu
:
200m
memory
:
500Mi
requests
:
cpu
:
100m
memory
:
100Mi
terminationMessagePath
:
/dev/termination-log
terminationMessagePolicy
:
File
dnsPolicy
:
ClusterFirst
restartPolicy
:
Always
terminationGracePeriodSeconds
:
30
---
apiVersion
:
v1
kind
:
Service
metadata
:
labels
:
app
:
$APP_NAME
name
:
$APP_NAME
namespace
:
$NAMESPACE
spec
:
ports
:
-
name
:
http
port
:
80
protocol
:
TCP
targetPort
:
80
selector
:
app
:
$APP_NAME
sessionAffinity
:
None
type
:
ClusterIP
nginx.conf
0 → 100644
View file @
0aae32c7
server
{
listen
80
;
server_name
localhost
;
#vue项目的打包后的dist
root
/var/www/html
;
location
/
{
add_header
Access-Control-Allow-Origin
*
;
add_header
X-Frame-Options
ALLOWALL
;
add_header
X-Content-Type-Options
nosniff
;
add_header
X-XSS-Protection
"1
;
mode=block"
;
try_files
$uri
$uri
/
@router
;
#需要指向下面的@router否则会出现vue的路由在nginx中刷新出现404
index
index.html
index.htm
;
}
#对应上面的@router,主要原因是路由的路径资源并不是一个真实的路径,所以无法找到具体的文件
#因此需要rewrite到index.html中,然后交给路由在处理请求资源
location
@router
{
rewrite
^.*
$
/index.html
last
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment