Skip to content

Commit

Permalink
chore: docker compose 변경(Docker-dev, prod 분리)
Browse files Browse the repository at this point in the history
  • Loading branch information
clean2001 committed Oct 29, 2024
1 parent 3877439 commit d6d8255
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 35 deletions.
11 changes: 0 additions & 11 deletions .github/workflows/aws-cicd-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -146,17 +146,6 @@ jobs:
sudo chown -R ubuntu:ubuntu /home/ubuntu/layer-api/infra/${{ env.DEPLOY_TARGET }}
- name: Set Permissions on Transferred Files
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.AWS_DEV_INSTANCE_HOST }}
username: ubuntu
key: ${{ secrets.AWS_INSTANCE_PEM }}
port: 22
script: |
sudo chmod -R 755 /home/ubuntu/layer-api/infra/${{ env.DEPLOY_TARGET }}
sudo chown -R ubuntu:ubuntu /home/ubuntu/layer-api/infra/${{ env.DEPLOY_TARGET }}
- name: Deploy with Docker Compose
uses: appleboy/ssh-action@master
with:
Expand Down
23 changes: 8 additions & 15 deletions .github/workflows/aws-cicd-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ jobs:
run: |
echo "${APPLICATION_SECRET_PROPERTIES}" > ./layer-api/src/main/resources/application-secret.properties
echo "${APPLICATION_SECRET_PROPERTIES}" > ./layer-batch/src/main/resources/application-secret.properties
echo "${GOOGLE_CREDENTIALS}" > ./layer-api/src/main/resources/tokens/StoredCredential
- name: Build layer-api module
run: ./gradlew :layer-api:build
Expand Down Expand Up @@ -86,13 +85,10 @@ jobs:
${{ env.REGISTRY }}/${{ env.NAMESPACE }}/${{ env.IMAGE_NAME }}_layer-batch
- name: Push layer-api Docker Image
uses: docker/build-push-action@v4
with:
context: ./layer-api
platforms: linux/amd64
push: true
tags: |
${{ env.REGISTRY }}/${{ env.NAMESPACE }}/${{ env.IMAGE_NAME }}_layer-api:latest
run: |
docker login -u ${{ secrets.DOCKER_EAMIL }} -p ${{ secrets.DOCKER_PASSWORD }}
docker build -f ./layer-api/Dockerfile-dev -t ${{ env.REGISTRY }}/${{ env.NAMESPACE }}/${{ env.IMAGE_NAME }}_layer-api:latest .
docker push ${{ env.REGISTRY }}/${{ env.NAMESPACE }}/${{ env.IMAGE_NAME }}_layer-api
- name: Push layer-batch Docker Image
uses: docker/build-push-action@v4
Expand All @@ -118,9 +114,6 @@ jobs:
run: |
echo "${{ secrets.APPLICATION_SECRET_PROPERTIES }}" > ./layer-api/infra/${{ env.DEPLOY_TARGET }}/application-secret.properties
echo "${{ secrets.APPLICATION_SECRET_PROPERTIES }}" > ./layer-batch/src/main/resources/application-secret.properties
sudo chmod 777 ./layer-api/infra/${{ env.DEPLOY_TARGET }}/tokens/StoredCredential
# echo "${GOOGLE_CREDENTIALS}" > ./layer-api/src/main/resources/tokens/StoredCredential
# echo "${GOOGLE_CREDENTIALS}" > ./layer-api/infra/aws/StoredCredential
- name: Archive Files
run: |
Expand All @@ -131,7 +124,7 @@ jobs:
with:
host: ${{ secrets.AWS_PROD_INSTANCE_HOST }}
username: ubuntu
key: ${{ secrets.AWS_PROD_INSTANCE_PEM }}
key: ${{ secrets.AWS_INSTANCE_PEM }}
port: 22
source: "layer-api.tar.gz"
target: "/home/ubuntu"
Expand All @@ -141,7 +134,7 @@ jobs:
with:
host: ${{ secrets.AWS_PROD_INSTANCE_HOST }}
username: ubuntu
key: ${{ secrets.AWS_PROD_INSTANCE_PEM }}
key: ${{ secrets.AWS_INSTANCE_PEM }}
port: 22
script: |
cd /home/ubuntu
Expand All @@ -155,7 +148,7 @@ jobs:
with:
host: ${{ secrets.AWS_PROD_INSTANCE_HOST }}
username: ubuntu
key: ${{ secrets.AWS_PROD_INSTANCE_PEM }}
key: ${{ secrets.AWS_INSTANCE_PEM }}
port: 22
script: |
sudo chmod -R 755 /home/ubuntu/layer-api/infra/${{ env.DEPLOY_TARGET }}
Expand All @@ -166,7 +159,7 @@ jobs:
with:
host: ${{ secrets.AWS_PROD_INSTANCE_HOST }}
username: ubuntu
key: ${{ secrets.AWS_PROD_INSTANCE_PEM }}
key: ${{ secrets.AWS_INSTANCE_PEM }}
port: 22
script: |
sudo apt update
Expand Down
6 changes: 0 additions & 6 deletions layer-api/Dockerfile → layer-api/Dockerfile-dev
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
FROM openjdk:17

ARG JAR_FILE=./build/libs/*.jar
ARG SPRING_PROFILE

COPY ${JAR_FILE} layer-server.jar

ENV SPRING_PROFILE=${SPRING_PROFILE}

ENTRYPOINT ["java", "-Duser.timezone=Asia/Seoul","-Dspring.profiles.active=dev" ,"-jar" ,"layer-server.jar"]
4 changes: 4 additions & 0 deletions layer-api/Dockerfile-prod
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FROM openjdk:17
ARG JAR_FILE=./build/libs/*.jar
COPY ${JAR_FILE} layer-server.jar
ENTRYPOINT ["java", "-Duser.timezone=Asia/Seoul","-Dspring.profiles.active=prod" ,"-jar" ,"layer-server.jar"]
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ private void setHttp(HttpSecurity http) throws Exception {
.requestMatchers(new AntPathRequestMatcher("/api/auth/oauth2/apple")).permitAll()
.requestMatchers(new AntPathRequestMatcher("/api/auth/create-token")).permitAll()
.requestMatchers(new AntPathRequestMatcher("/admin/**")).permitAll()
.requestMatchers(new AntPathRequestMatcher("/greeting")).permitAll()
.anyRequest().authenticated()
)
.headers(headers -> headers
Expand Down
13 changes: 13 additions & 0 deletions layer-api/src/main/java/org/layer/domain/etc/TempController.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package org.layer.domain.etc;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class TempController {
@GetMapping("/greeting")
public String greeting(@Value("${greeting.message}") String greeting) {
return greeting;
}
}
5 changes: 4 additions & 1 deletion layer-api/src/main/resources/application-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,7 @@ openai:
maxTokens: ${OPENAI_MAX_TOKENS}

admin:
password: ${ADMIN_PASSWORD}
password: ${ADMIN_PASSWORD}

greeting:
message: this is dev
5 changes: 4 additions & 1 deletion layer-api/src/main/resources/application-local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,7 @@ openai:
maxTokens: ${OPENAI_MAX_TOKENS}

admin:
password: ${ADMIN_PASSWORD}
password: ${ADMIN_PASSWORD}

greeting:
message: this is local
5 changes: 4 additions & 1 deletion layer-api/src/main/resources/application-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,7 @@ openai:
maxTokens: ${OPENAI_MAX_TOKENS}

admin:
password: ${ADMIN_PASSWORD}
password: ${ADMIN_PASSWORD}

greeting:
message: this is prod

0 comments on commit d6d8255

Please sign in to comment.