Skip to content

Commit

Permalink
클라우드-서비스-변경에따른-CD수정-(라즈베리파이) (#44)
Browse files Browse the repository at this point in the history
* Refactor : 리눅스 arm64 빌드 추가

* Minor : 포트명 제거
  • Loading branch information
jobkaeHenry authored Nov 26, 2023
1 parent c83c76e commit 565aeaf
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 7 deletions.
9 changes: 6 additions & 3 deletions .github/workflows/Client-DEV-CD.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@ jobs:
with:
fetch-depth: 0

- name: Docker Setup Buildx
uses: docker/[email protected]

- name: Build Docker Image
run: docker build -f Dockerfile --build-arg NEXT_PUBLIC_BASE_URL=${{secrets.NEXT_PUBLIC_BASE_URL}} --build-arg NEXT_PUBLIC_CLIENT_BASE_URL=${{secrets.NEXT_PUBLIC_CLIENT_BASE_URL}} --build-arg PORT=${{secrets.CLIENT_DEV_PORT}} -t ${{ secrets.CLIENT_STORYBOOK_REPO }}/${{ secrets.CLIENT_DEV_SERVICE_NAME }}:latest .
run: docker buildx build --platform linux/amd64,linux/arm64 -f Dockerfile --build-arg NEXT_PUBLIC_BASE_URL=${{secrets.NEXT_PUBLIC_BASE_URL}} --build-arg NEXT_PUBLIC_CLIENT_BASE_URL=${{secrets.NEXT_PUBLIC_CLIENT_BASE_URL}} --build-arg PORT=${{secrets.CLIENT_DEV_PORT}} -t ${{ secrets.CLIENT_STORYBOOK_REPO }}/${{ secrets.CLIENT_DEV_SERVICE_NAME }}:latest .
working-directory: ./client

- name: Login to Docker Hub
Expand All @@ -30,11 +33,11 @@ jobs:
uses: appleboy/[email protected]
with:
host: ${{ secrets.STORYBOOK_CLOUD_HOST }}
username: root
username: ${{ secrets.CLOUD_USERNAME }}
password: ${{ secrets.STORYBOOK_CLOUD_PASSWORD }}
port: ${{ secrets.STORYBOOK_CLOUD_PORT }}
script: |
sudo docker pull ${{ secrets.CLIENT_STORYBOOK_REPO }}/${{ secrets.CLIENT_DEV_SERVICE_NAME }}:latest
sudo docker rm -f ${{ secrets.CLIENT_DEV_SERVICE_NAME }}
sudo docker run --name ${{ secrets.CLIENT_DEV_SERVICE_NAME }} -d -e PORT=${{secrets.CLIENT_DEV_PORT}} -p ${{ secrets.CLIENT_DEV_PORT }}:${{ secrets.CLIENT_DEV_PORT }} ${{ secrets.CLIENT_STORYBOOK_REPO }}/${{ secrets.CLIENT_DEV_SERVICE_NAME }}:latest
sudo docker run --name ${{ secrets.CLIENT_DEV_SERVICE_NAME }} -d -p ${{ secrets.CLIENT_DEV_PORT }}:${{ secrets.CLIENT_DEV_PORT }} ${{ secrets.CLIENT_STORYBOOK_REPO }}/${{ secrets.CLIENT_DEV_SERVICE_NAME }}:latest
docker image prune -f
2 changes: 1 addition & 1 deletion client/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ ARG PORT=3000
ARG NEXT_PUBLIC_CLIENT_BASE_URL

ENV NEXT_PUBLIC_BASE_URL ${NEXT_PUBLIC_BASE_URL}
ENV NEXT_PUBLIC_CLIENT_BASE_URL ${NEXT_PUBLIC_CLIENT_BASE_URL}:${PORT}
ENV NEXT_PUBLIC_CLIENT_BASE_URL ${NEXT_PUBLIC_CLIENT_BASE_URL}

RUN yarn build

Expand Down
22 changes: 19 additions & 3 deletions client/src/app/api/auth/login/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { LOGIN_API_PATH } from "@/const/serverPath";
import { setCookie } from "@/hooks/useSetCookie";
import axios from "@/libs/axios";
import { SigninResponseInterface } from "@/types/auth/signinResponse";
import { AxiosResponse, isAxiosError } from "axios";
import { isAxiosError } from "axios";
import { NextRequest, NextResponse } from "next/server";

export async function POST(request: NextRequest) {
Expand All @@ -13,7 +13,16 @@ export async function POST(request: NextRequest) {
password,
});
setCookie({ key: "accessToken", value: data.token, httpOnly: true });
return NextResponse.json({ ...data });
return NextResponse.json(
{ ...data },
{
headers: {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, OPTIONS",
"Access-Control-Allow-Headers": "Content-Type, Authorization",
},
}
);
} catch (error) {
if (
isAxiosError<{
Expand All @@ -26,7 +35,14 @@ export async function POST(request: NextRequest) {
const { httpStatus, errorMessage, detailMessage } = error.response?.data;
return NextResponse.json(
{ errorMessage, detailMessage, httpStatus },
{ status: httpStatus }
{
status: httpStatus,
headers: {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, OPTIONS",
"Access-Control-Allow-Headers": "Content-Type, Authorization",
},
}
);
}
}
Expand Down

0 comments on commit 565aeaf

Please sign in to comment.