diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..cf9ad49 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,40 @@ +name: Deploy Production + +on: + push: + branches: + - main + +jobs: + build: + name: Build Image + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v1 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: us-west-2 + - name: Login to Amazon ECR + id: login-ecr + uses: aws-actions/amazon-ecr-login@v1 + - name: Build, tag, and push image to Amazon ECR + env: + ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} + ECR_REPOSITORY: web3logo-backend + IMAGE_TAG: ${{ github.sha }} + run: | + docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG . + docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG + - name: Deploy to server + uses: appleboy/ssh-action@master + with: + host: server1.lxdao.io + username: root + key: ${{ secrets.SSH_PRIVATE_KEY }} + port: 22 + script: | + /root/apps/web3logo-backend.sh 653640199626.dkr.ecr.us-west-2.amazonaws.com/web3logo-backend:${{ github.sha }} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..5a1d031 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,13 @@ +FROM node:16 + +# RUN apt-get update \ +# && apt-get install -qq build-essential libcairo2-dev libpango1.0-dev libjpeg-dev libgif-dev librsvg2-dev + +WORKDIR /app/ +COPY . . +RUN npm config set strict-ssl false \ + && npm install \ + && npm run build + +EXPOSE 80 +CMD [ "npm", "start" ] \ No newline at end of file diff --git a/src/main.ts b/src/main.ts index 3ca7f8d..6503183 100644 --- a/src/main.ts +++ b/src/main.ts @@ -25,6 +25,6 @@ async function bootstrap() { app.useGlobalPipes(new ValidationPipe()); app.useGlobalInterceptors(new TransformInterceptor()); - await app.listen(3000); + await app.listen(process.env.PORT || 3000); } bootstrap();