Skip to content

Commit 7dbacd9

Browse files
authored
Merge pull request #9 from sartim/develop
Update main branch
2 parents 409758b + 0e9c3bf commit 7dbacd9

File tree

4 files changed

+26
-132
lines changed

4 files changed

+26
-132
lines changed

.github/workflows/develop.yml

+12-64
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ on:
77
jobs:
88
test:
99
runs-on: ubuntu-latest
10+
environment: testing
1011
services:
1112
postgres:
1213
image: postgres:10.8
@@ -17,11 +18,12 @@ jobs:
1718
ports:
1819
- 5432:5432
1920
steps:
20-
- uses: actions/checkout@v3
21+
- uses: actions/checkout@v4
2122
- name: Run unit tests
2223
run: echo "Run unit tests"
2324
build:
2425
runs-on: ubuntu-latest
26+
environment: staging
2527
services:
2628
postgres:
2729
image: postgres:10.8
@@ -35,67 +37,13 @@ jobs:
3537
strategy:
3638
max-parallel: 1
3739
steps:
38-
- uses: actions/checkout@v3
39-
- name: Setup CI/CD Server
40+
- uses: actions/checkout@v4
41+
- name: Build Docker image
4042
run: |
41-
sudo apt-get update &&
42-
sudo apt-get install -y redis-server git &&
43-
sudo apt-get install -y cmake g++ gcc libjsoncpp-dev uuid-dev openssl &&
44-
sudo apt-get install -y libssl-dev zlib1g-dev libbz2-dev liblzma-dev &&
45-
sudo apt-get install -y postgresql postgresql-contrib &&
46-
sudo apt-get clean && sudo rm -rf /var/lib/apt/lists/*
47-
- name: Install Drogon Framework
48-
run: |
49-
git clone https://github.com/drogonframework/drogon
50-
cd drogon &&
51-
git submodule update --init &&
52-
sudo mkdir build && cd build && sudo cmake .. && sudo make && sudo make install
53-
- name: Install JWT CPP Library
54-
run: |
55-
git clone https://github.com/Thalhammer/jwt-cpp.git
56-
cd jwt-cpp && mkdir build && cd build && sudo cmake .. && sudo make && sudo make install
57-
- name: Install Bcrypt CPP Library
58-
run: |
59-
git clone https://github.com/hilch/Bcrypt.cpp.git
60-
- name: Run Scripts
61-
run: |
62-
sudo chmod +x ./scripts/create_dot_env.sh
63-
./scripts/create_dot_env.sh
64-
env:
65-
SECRET_KEY: ${{secrets.SECRET_KEY}}
66-
DB_NAME: ${{secrets.DB_NAME}}
67-
DB_USER: ${{secrets.DB_USER}}
68-
DB_PASS: ${{secrets.DB_PASS}}
69-
- name: Build
70-
run: |
71-
mkdir build && cd build && cmake .. && make
72-
- name: Compress binary
73-
run: |
74-
sudo mkdir drogon_user_service
75-
sudo cp .env drogon_user_service
76-
cd drogon_user_service && sudo zip -r drogon_user_service_stage.zip .
77-
- name: Upload compressed binary to S3
78-
# run: |
79-
# aws s3 cp drogon_user_service/drogon_user_service_stage.zip ${{ secrets.SMS_GATEWAY_S3_URI }}/drogon_user_service_stage.zip --region ${{ secrets.AWS_REGION }}
80-
run: echo "Upload to aws s3 here"
81-
env:
82-
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
83-
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
84-
deploy:
85-
runs-on: ubuntu-latest
86-
needs: build
87-
strategy:
88-
max-parallel: 1
89-
steps:
90-
- uses: actions/checkout@v3
91-
- name: Setup CI/CD Server
92-
run: |
93-
sudo apt-get update &&
94-
sudo apt-get install -y redis-server &&
95-
sudo apt-get install -y awscli
96-
- name: Deploy to stage
97-
# run: aws deploy create-deployment --region ${{ secrets.AWS_REGION }} --application-name sms-gateway --deployment-config-name CodeDeployDefault.OneAtATime --deployment-group-name sms-gateway-server-2-dg --description "Github deployment for commit ${GITHUB_SHA}" --s3-location bucket=eneza-sms-gateway,key=sms-gateway-bundle-stage.zip,bundleType=zip
98-
run: echo "Create codedeploy deployment"
99-
env:
100-
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
101-
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
43+
docker build \
44+
--build-arg SECRET_KEY=${{ secrets.SECRET_KEY }} \
45+
--build-arg DB_HOST=${{ secrets.DB_HOST }} \
46+
--build-arg DB_NAME=${{ secrets.DB_NAME }} \
47+
--build-arg DB_USER=${{ secrets.DB_USER }} \
48+
--build-arg DB_PASSWORD=${{ secrets.DB_PASSWORD }} \
49+
-t user_service:latest .

.github/workflows/main.yml

+11-64
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
ports:
1818
- 5432:5432
1919
steps:
20-
- uses: actions/checkout@v3
20+
- uses: actions/checkout@v4
2121
- name: Run unit tests
2222
run: echo "Run unit tests"
2323
build:
@@ -35,67 +35,14 @@ jobs:
3535
strategy:
3636
max-parallel: 1
3737
steps:
38-
- uses: actions/checkout@v3
39-
- name: Setup CI/CD Server
38+
- uses: actions/checkout@v4
39+
- name: Build Docker image
4040
run: |
41-
sudo apt-get update &&
42-
sudo apt-get install -y redis-server git &&
43-
sudo apt-get install -y cmake g++ gcc libjsoncpp-dev uuid-dev openssl &&
44-
sudo apt-get install -y libssl-dev zlib1g-dev libbz2-dev liblzma-dev &&
45-
sudo apt-get install -y postgresql postgresql-contrib &&
46-
sudo apt-get clean && sudo rm -rf /var/lib/apt/lists/*
47-
- name: Install Drogon Framework
48-
run: |
49-
git clone https://github.com/drogonframework/drogon
50-
cd drogon &&
51-
git submodule update --init &&
52-
sudo mkdir build && cd build && sudo cmake .. && sudo make && sudo make install
53-
- name: Install JWT CPP Library
54-
run: |
55-
git clone https://github.com/Thalhammer/jwt-cpp.git
56-
cd jwt-cpp && mkdir build && cd build && sudo cmake .. && sudo make && sudo make install
57-
- name: Install Bcrypt CPP Library
58-
run: |
59-
git clone https://github.com/hilch/Bcrypt.cpp.git
60-
- name: Run Scripts
61-
run: |
62-
sudo chmod +x ./scripts/create_dot_env.sh
63-
./scripts/create_dot_env.sh
64-
env:
65-
SECRET_KEY: ${{secrets.SECRET_KEY}}
66-
DB_NAME: ${{secrets.DB_NAME}}
67-
DB_USER: ${{secrets.DB_USER}}
68-
DB_PASS: ${{secrets.DB_PASS}}
69-
- name: Build
70-
run: |
71-
mkdir build && cd build && cmake .. && make
72-
- name: Compress binary
73-
run: |
74-
sudo mkdir drogon_user_service
75-
sudo cp .env drogon_user_service
76-
cd drogon_user_service && sudo zip -r drogon_user_service_prod.zip .
77-
- name: Upload compressed binary to S3
78-
# run: |
79-
# aws s3 cp drogon_user_service/drogon_user_service_prod.zip ${{ secrets.SMS_GATEWAY_S3_URI }}/drogon_user_service_prod.zip --region ${{ secrets.AWS_REGION }}
80-
run: echo "Upload to aws s3 here"
81-
env:
82-
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
83-
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
84-
deploy:
85-
runs-on: ubuntu-latest
86-
needs: build
87-
strategy:
88-
max-parallel: 1
89-
steps:
90-
- uses: actions/checkout@v3
91-
- name: Setup CI/CD Server
92-
run: |
93-
sudo apt-get update &&
94-
sudo apt-get install -y redis-server &&
95-
sudo apt-get install -y awscli
96-
- name: Deploy to prod
97-
# run: aws deploy create-deployment --region ${{ secrets.AWS_REGION }} --application-name sms-gateway --deployment-config-name CodeDeployDefault.OneAtATime --deployment-group-name sms-gateway-server-2-dg --description "Github deployment for commit ${GITHUB_SHA}" --s3-location bucket=eneza-sms-gateway,key=sms-gateway-bundle-prod.zip,bundleType=zip
98-
run: echo "Create codedeploy deployment"
99-
env:
100-
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
101-
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
41+
docker build \
42+
--build-arg SECRET_KEY=${{ secrets.SECRET_KEY }} \
43+
--build-arg DB_HOST=${{ secrets.DB_HOST }} \
44+
--build-arg DB_NAME=${{ secrets.DB_NAME }} \
45+
--build-arg DB_USER=${{ secrets.DB_USER }} \
46+
--build-arg DB_PASSWORD=${{ secrets.DB_PASSWORD }} \
47+
-t user_service:latest .
48+

Dockerfile

+2-3
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ ARG DB_HOST
55
ARG DB_PORT
66
ARG DB_NAME
77
ARG DB_USER
8-
ARG DB_PASS
8+
ARG DB_PASSWORD
99

1010
ENV SECRET_KEY=$SECRET_KEY
1111
ENV DB_HOST=$DB_HOST
1212
ENV DB_PORT=$DB_PORT
1313
ENV DB_NAME=$DB_NAME
1414
ENV DB_USER=$DB_USER
15-
ENV DB_PASS=$DB_PASS
15+
ENV DB_PASSWORD=$DB_PASSWORD
1616

1717
# Set the timezone
1818
ENV TZ=America/New_York
@@ -42,7 +42,6 @@ RUN cd jwt-cpp && mkdir build && cd build && cmake .. && make && make install
4242

4343

4444
# Copy the application code
45-
# WORKDIR /app
4645
COPY . .
4746

4847
# Install brcrypt

scripts/create_dot_env.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ SECRET_KEY=${SECRET_KEY}
55
DB_HOST=${DB_HOST}
66
DB_NAME=${DB_NAME}
77
DB_USER=${DB_USER}
8-
DB_PASSWORD=${DB_PASS}
8+
DB_PASSWORD=${DB_PASSWORD}
99
EOF

0 commit comments

Comments
 (0)