ngnix μ€μ νμΌ
user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;
events {
worker_connections 768;
# multi_accept on;
}
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# server_tokens off;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
##
# SSL Settings
##
ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;
##
# Logging Settings
##
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
##
# Gzip Settings
##
gzip on;
# gzip_vary on;
# gzip_proxied any;
# gzip_comp_level 6;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
# gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
##
# Virtual Host Configs
##
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
server {
listen 80;
server_name www.ssafast.com;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl;
ssl_certificate /etc/letsencrypt/live/www.ssafast.com/fullchain.pem; # managed by Cert>
ssl_certificate_key /etc/letsencrypt/live/www.ssafast.com/privkey.pem; # managed by Ce>
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Ce rtbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Cert bot
location /oauth2 {
proxy_pass <http://www.ssafast.com:8080>;
}
location /login/oauth2 {
proxy_pass <http://www.ssafast.com:8080>;
}
location /google-loading {
proxy_pass <http://localhost:3000>;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
}
location /api/figma {
proxy_pass <http://localhost:3000>;
}
location /api/figma-images {
proxy_pass <http://localhost:3000>;
}
location /api/figma-token-gen {
proxy_pass <http://localhost:3000>;
}
location / {
proxy_pass <http://localhost:3000>;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
}
location /ws{
proxy_pass <http://0.0.0.0:5555>;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade"; λ‘ λ¦¬λ€μ΄λ νΈνλμ§
}
location /api { # location μ΄ν νΉμ urlμ μ²λ¦¬νλ λ°©λ²μ μ μ
proxy_pass <http://localhost:8080>; # Requestμ λν΄ μ΄λ λ‘ λ¦¬λ€μ΄λ νΈνλμ§
}
}
}
#mail {
# # See sample authentication script at:
# # <http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript>
#
# # auth_http localhost/auth.php;
# # pop3_capabilities "TOP" "USER";
# # imap_capabilities "IMAP4rev1" "UIDPLUS";
#
# server {
# listen localhost:110;
# protocol pop3;
# proxy on;
Backend Dockerfile
FROM openjdk:8-jdk
ARG JAR_FILE=build/libs/ssafast-0.0.1-SNAPSHOT.jar
COPY ${JAR_FILE} app.jar
ENTRYPOINT ["java","-Duser.timezone=Asia/Seoul","-jar","/app.jar"]
Frontend Dockerfile
# base image
FROM node:lts as build
# working directory
WORKDIR /app
# copy package.json and package-lock.json to container
COPY package*.json ./
# install dependencies
RUN npm install
# copy the rest of the application code to the container
COPY . .
# start build
RUN npm run build
EXPOSE 3000
CMD ["sh", "-c", "PORT=4444 node ./node_modules/y-webrtc/bin/server.js & npm start"]
Jenkins pipeline script
Backend container
pipeline {
agent any
stages {
stage('Gitlab') {
steps {
git branch: 'develop/BE', credentialsId: 'gitlab-access-account', url: '<https://lab.ssafy.com/s08-final/S08P31A502.git>'
}
}
stage('SpringBootBuild') {
steps {
dir('backend') {
sh "cp /home/env/backend/application.yml /var/jenkins_home/workspace/ssafast-back/backend/src/main/resources/application.yml"
sh "chmod +x gradlew"
sh "./gradlew build"
}
}
}
stage('Build') {
steps {
sh 'docker build -t ssafast-back ./backend/'
}
}
stage("Stop and Remove Back Container") {
steps {
script {
def result = sh(returnStdout: true, script: "docker ps -a -q --filter name=ssafast-back")
if (result.trim().length() > 0) {
sh "docker stop ssafast-back"
sh "docker rm ssafast-back"
echo "Container named 'ssafast-back' has been stopped and removed."
} else {
echo "No container named 'ssafast-back' was found."
}
}
}
}
stage('Deploy') {
steps{
sh 'docker run -d -p 8080:8080 --name ssafast-back ssafast-back'
}
}
stage('Finish') {
steps{
sh 'docker images -qf dangling=true | xargs -I{} docker rmi {}'
}
}
}
}
Frontend container
pipeline {
agent any
tools {nodejs "node-LTS"}
stages {
stage('Gitlab') {
steps {
git branch: 'develop/FE', credentialsId: 'gitlab-access-account', url: '<https://lab.ssafy.com/s08-final/S08P31A502.git>'
}
}
stage('Dependency Install') {
steps {
dir('frontend') {
sh "npm install"
}
}
}
stage('Build') {
steps {
dir('frontend') {
sh "cp /home/env/frontend/.env /var/jenkins_home/workspace/ssafast-front/frontend/.env"
sh 'docker build -t ssafast-front .'
}
}
}
stage("Stop and Remove Front Container") {
steps {
script {
def result = sh(returnStdout: true, script: "docker ps -a -q --filter name=ssafast-front")
if (result.trim().length() > 0) {
sh "docker stop ssafast-front"
sh "docker rm ssafast-front"
echo "Container named 'ssafast-front' has been stopped and removed."
} else {
echo "No container named 'ssafast-front' was found."
}
}
}
}
stage('Deploy') {
steps{
sh 'docker run -d -p 3000:3000 -p 5555:4444 --name ssafast-front ssafast-front'
}
}
stage('Finish') {
steps{
sh 'docker images -qf dangling=true | xargs -I{} docker rmi {}'
}
}
}
}