Skip to content
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
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ COPY --from=build /usr/src/app /usr/src/app
WORKDIR /usr/src/app

COPY ./code/ .
EXPOSE 80
ENV PORT 5000
EXPOSE 5000

CMD ["node", "main.js"]
70 changes: 49 additions & 21 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,22 +1,50 @@
node {
def app
stage('Clone repository') {
git 'https://github.com/KimGeunHye21/Wimb_DevOps.git'
}
stage('Build image') {
app = docker.build("kimgeunhye21/wimb")
}
stage('Test image') {
app.inside{
// sh'make test'
}
}
stage('Push image') {
docker.withRegistry('https://registry.hub.docker.com', 'kimgeunhye21') {
app.push("${env.BUILD_NUMBER}")
app.push("latest")
}
}
pipeline {
agent any
environment {
PROJECT_ID = 'my-project-2024-442302'
CLUSTER_NAME = 'kube'
LOCATION = 'asia-northeast3-a'
CREDENTIALS_ID = 'gke'
}
stages {
stage("Checkout code") {
steps {
checkout scm
}
}
stage("Copy .env file") {
steps {
script {
sh "cp /var/jenkins_home/.env ./code/.env"
}
}
}
stage("Build image") {
steps {
script {
myapp = docker.build("kimgeunhye21/wimb:${env.BUILD_ID}")
}
}
}
stage("Push image") {
steps {
script {
docker.withRegistry('https://registry.hub.docker.com', 'kimgeunhye21') {
myapp.push("latest")
myapp.push("${env.BUILD_ID}")
}
}
}
}
stage('Deploy to GKE') {
when {
branch 'main'
}
steps{
sh "sed -i 's/wimb:latest/wimb:${env.BUILD_ID}/g' deployment.yaml"
step([$class: 'KubernetesEngineBuilder', projectId: env.PROJECT_ID, clusterName: env.CLUSTER_NAME, location: env.LOCATION, manifestPattern: 'deployment.yaml', credentialsId: env.CREDENTIALS_ID,
verifyDeployments: true])
}
}
}
}

// pr기반 테스트1
43 changes: 43 additions & 0 deletions deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: wimb
labels:
app: wimb
spec:
replicas: 3
strategy:
type: Recreate
selector:
matchLabels:
app: wimb
template:
metadata:
labels:
app: wimb
tier: wimb
spec:
containers:
- name: wimb
image: kimgeunhye21/wimb:latest
imagePullPolicy: Always
ports:
- containerPort: 5000
name: wimb

---

apiVersion: v1
kind: Service
metadata:
name: wimb
labels:
app: wimb
spec:
ports:
- port: 80
targetPort: 5000
selector:
app: wimb
tier: wimb
type: LoadBalancer