forked from kookmin-sw/cap-template
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
82 changed files
with
668 additions
and
559 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
name: Deploy Server | ||
|
||
on: | ||
push: | ||
branches: [ "feature/be/#115-CICD" ] | ||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v1 | ||
|
||
- name: Create env file | ||
run: | | ||
echo DB_ENDPOINT=${{ secrets.DB_ENDPOINT }} >> .env | ||
echo DB_NAME=${{ secrets.DB_NAME }} >> .env | ||
echo MYSQL_USERNAME=${{ secrets.MYSQL_USERNAME }} >> .env | ||
echo MYSQL_PASSWORD=${{ secrets.MYSQL_PASSWORD }} >> .env | ||
echo JWT_SECRET=${{ secrets.JWT_SECRET }} >> .env | ||
echo JWT_ACCESS_EXPIRATION_TIME=${{ secrets.JWT_ACCESS_EXPIRATION_TIME }} >> .env | ||
echo JWT_REFRESH_EXPIRATION_TIME=${{ secrets.JWT_REFRESH_EXPIRATION_TIME }} >> .env | ||
echo HMAC_SECRET=${{ secrets.HMAC_SECRET }} >> .env | ||
echo HMAC_ALGORITHM=${{ secrets.HMAC_ALGORITHM }} >> .env | ||
echo DeepL_API_KEY=${{ secrets.DeepL_API_KEY }} >> .env | ||
echo TEST_KEY=${{ secrets.TEST_KEY }} >> .env | ||
echo Azure_API_KEY=${{ secrets.Azure_API_KEY }} >> .env | ||
echo REDIS_HOST=${{ secrets.REDIS_HOST }} >> .env | ||
echo REDIS_PORT=${{ secrets.REDIS_PORT }} >> .env | ||
echo S3_ACCESS_KEY=${{ secrets.S3_ACCESS_KEY }} >> .env | ||
echo S3_SECRET_KEY=${{ secrets.S3_SECRET_KEY }} >> .env | ||
- name: Login to DockerHub | ||
uses: docker/login-action@v1 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
|
||
- name: Build and push Spring | ||
uses: docker/build-push-action@v2 | ||
with: | ||
context: . | ||
push: true | ||
file: ./back/Dockerfile | ||
tags: ${{ secrets.DOCKER_REPO }}/spring:latest | ||
cache-from: type=gha | ||
cache-to: type=gha,mode=max | ||
|
||
- name: Build and push Nginx | ||
uses: docker/build-push-action@v2 | ||
with: | ||
context: . | ||
push: true | ||
file: ./back/nginx/Dockerfile | ||
tags: ${{ secrets.DOCKER_REPO }}/nginx:latest | ||
cache-from: type=gha | ||
cache-to: type=gha,mode=max | ||
|
||
- name: Build and push Ruby on Rails | ||
uses: docker/build-push-action@v2 | ||
with: | ||
context: . | ||
push: true | ||
file: ./back-chat/Dockerfile | ||
tags: ${{ secrets.DOCKER_REPO }}/ruby:latest | ||
cache-from: type=gha | ||
cache-to: type=gha,mode=max | ||
|
||
- name: Copy docker-compose.yaml to EC2 | ||
uses: appleboy/scp-action@master | ||
with: | ||
host: ${{ secrets.HOST }} | ||
username: ubuntu | ||
key: ${{ secrets.KEY }} | ||
source: "/github/workspace/back/docker-compose.yaml" | ||
target: "/home/ubuntu/capstone" | ||
|
||
- name: Copy .env to EC2 | ||
uses: appleboy/scp-action@master | ||
with: | ||
host: ${{ secrets.HOST }} | ||
username: ubuntu | ||
key: ${{ secrets.KEY }} | ||
source: "/github/workspace/.env" | ||
target: "/home/ubuntu/capstone" | ||
|
||
- name: executing remote ssh commands using password | ||
uses: appleboy/ssh-action@master | ||
with: | ||
host: ${{ secrets.AWS_HOST }} | ||
username: ubuntu | ||
key: ${{ secrets.AWS_KEY }} | ||
script: | | ||
if [ "$(sudo docker ps -qa)" ]; then | ||
sudo docker rm -f $(sudo docker ps -qa) | ||
fi | ||
sudo docker pull ${{ secrets.DOCKER_REPO }}/spring:latest | ||
sudo docker pull ${{ secrets.DOCKER_REPO }}/nginx:latest | ||
sudo docker pull ${{ secrets.DOCKER_REPO }}/ruby:latest | ||
sudo docker-compose -f capstone/docker-compose.yml up -d | ||
sudo docker image prune -f |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
FROM ruby:3.0.2-slim | ||
|
||
WORKDIR /app | ||
|
||
RUN apt-get update | ||
RUN apt-get install -y build-essential apt-utils libpq-dev default-mysql-client default-libmysqlclient-dev | ||
|
||
COPY Gemfile Gemfile.lock ./ | ||
|
||
RUN gem install bundler && RAILS_ENV=production bundle install --jobs 20 --retry 5 | ||
|
||
ENV RAILS_ENV=production | ||
|
||
COPY . ./ | ||
|
||
FROM ruby:3.0.2-slim | ||
|
||
WORKDIR /app | ||
|
||
RUN apt-get update | ||
RUN apt-get install -y build-essential apt-utils libpq-dev default-mysql-client default-libmysqlclient-dev | ||
|
||
COPY Gemfile Gemfile.lock ./ | ||
|
||
RUN gem install bundler && RAILS_ENV=production bundle install --jobs 20 --retry 5 | ||
|
||
ENV RAILS_ENV=production | ||
|
||
COPY . ./ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,45 @@ | ||
source 'https://rubygems.org' | ||
git_source(:github) { |repo| "https://github.com/#{repo}.git" } | ||
|
||
ruby '3.0.2' | ||
|
||
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails', branch: 'main' | ||
gem 'rails', '~> 6.1.7', '>= 6.1.7.7' | ||
# Use mysql as the database for Active Record | ||
gem 'mysql2', '~> 0.5' | ||
|
||
# Use Puma as the app server | ||
gem 'puma', '~> 5.0' | ||
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder | ||
# gem 'jbuilder', '~> 2.7' | ||
# Use Redis adapter to run Action Cable in production | ||
# gem 'redis', '~> 4.0' | ||
# Use Active Model has_secure_password | ||
# gem 'bcrypt', '~> 3.1.7' | ||
|
||
# Use Active Storage variant | ||
# gem 'image_processing', '~> 1.2' | ||
|
||
# Reduces boot times through caching; required in config/boot.rb | ||
gem 'bootsnap', '>= 1.4.4', require: false | ||
|
||
# Use Rack CORS for handling Cross-Origin Resource Sharing (CORS), making cross-origin AJAX possible | ||
# gem 'rack-cors' | ||
|
||
group :development, :test do | ||
# Call 'byebug' anywhere in the code to stop execution and get a debugger console | ||
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw] | ||
end | ||
|
||
group :development do | ||
gem 'listen', '~> 3.3' | ||
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring | ||
gem 'spring' | ||
end | ||
|
||
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem | ||
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] | ||
|
||
gem 'dotenv-rails' | ||
|
||
source 'https://rubygems.org' | ||
git_source(:github) { |repo| "https://github.com/#{repo}.git" } | ||
|
||
ruby '3.0.2' | ||
|
||
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails', branch: 'main' | ||
gem 'rails', '~> 6.1.7', '>= 6.1.7.7' | ||
# Use mysql as the database for Active Record | ||
gem 'mysql2', '~> 0.5' | ||
|
||
# Use Puma as the app server | ||
gem 'puma', '~> 5.0' | ||
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder | ||
# gem 'jbuilder', '~> 2.7' | ||
# Use Redis adapter to run Action Cable in production | ||
# gem 'redis', '~> 4.0' | ||
# Use Active Model has_secure_password | ||
# gem 'bcrypt', '~> 3.1.7' | ||
|
||
# Use Active Storage variant | ||
# gem 'image_processing', '~> 1.2' | ||
|
||
# Reduces boot times through caching; required in config/boot.rb | ||
gem 'bootsnap', '>= 1.4.4', require: false | ||
|
||
# Use Rack CORS for handling Cross-Origin Resource Sharing (CORS), making cross-origin AJAX possible | ||
# gem 'rack-cors' | ||
|
||
group :development, :test do | ||
# Call 'byebug' anywhere in the code to stop execution and get a debugger console | ||
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw] | ||
end | ||
|
||
group :development do | ||
gem 'listen', '~> 3.3' | ||
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring | ||
gem 'spring' | ||
end | ||
|
||
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem | ||
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] | ||
|
||
gem 'dotenv-rails' | ||
|
||
gem 'jwt' |
Oops, something went wrong.