diff --git a/.github/workflows/develop_pull_request.yml b/.github/workflows/develop_pull_request.yml new file mode 100644 index 0000000..04fd787 --- /dev/null +++ b/.github/workflows/develop_pull_request.yml @@ -0,0 +1,57 @@ +name: Test and Build Docker Image to ECR + +on: + pull_request: + branches: + - main + +jobs: + build-and-test: + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [18] + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up Node ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + + - name: Cache node_modules + uses: actions/cache@v3 + with: + path: | + **/node_modules + key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} + restore-keys: ${{ runner.os }}-node- + + - name: Install dependencies + run: npm ci + + - name: Build + run: npm run build + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v2 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: ap-northeast-2 + + - name: Login to Amazon ECR + id: login-ecr + uses: aws-actions/amazon-ecr-login@v1 + + - name: Build and push image to ECR + env: + ECR_REGISTRY: ${{ secrets.AWS_ECR_REGISTRY }} + ECR_REPOSITORY: ${{ secrets.AWS_ECR_REPOSITORY }} + IMAGE_TAG: frontend-latest + run: | + docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG . + docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..1ff60f7 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,17 @@ +# Dockerfile for factoreal-FE + +FROM node:18 + +WORKDIR /app + +COPY package.json package-lock.json ./ +RUN npm install + +COPY . . + +ENV NODE_ENV=development +ENV HOST=0.0.0.0 + +EXPOSE 5173 + +CMD ["npm", "run", "dev", "--", "--host" ] \ No newline at end of file