Skip to content

Commit

Permalink
fix: upload asset
Browse files Browse the repository at this point in the history
  • Loading branch information
marcos committed Jan 30, 2024
2 parents ff49246 + c895b4e commit c41a2c5
Show file tree
Hide file tree
Showing 30 changed files with 726 additions and 135 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/qa.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Deploy Websockets for QA

on:
push:
branches: [main]
paths:
- .github/workflows/*.yaml
- src/**/*.ts
- Dockerfile.production
- package.json
- package-lock.json
- tools/**/*.js

jobs:
build:
name: Building a new docker image
runs-on: ubuntu-latest
environment: qa
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@v4
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '16.x'
- run: npm install
- run: npm run build
- name: Getting project info
id: project-info
run: node tools/info.js
- name: Build, tag, and push docker image to Amazon ECR
env:
REGISTRY: ${{ steps.login-ecr.outputs.registry }}
IMAGE_TAG: ${{ steps.project-info.outputs.version }}
REPOSITORY: vitruveo.studio.websocket
UPDATE_TOKEN: ${{ secrets.UPDATE_TOKEN }}
UPDATE_URL: ${{ secrets.UPDATE_URL }}
REPOSITORY_IMAGE: ${{ vars.REPOSITORY_IMAGE }}
run: |
docker build -t $REGISTRY/$REPOSITORY:$IMAGE_TAG.qa -f Dockerfile.production --network host .
docker push $REGISTRY/$REPOSITORY:$IMAGE_TAG.qa
curl -X "POST" -H 'Content-Type: application/json' -d "{\"token\":\"$UPDATE_TOKEN\",\"image\":\"$REPOSITORY_IMAGE:$IMAGE_TAG.qa\",\"service\":\"vitruveo-studio_websocket\"}" $UPDATE_URL
6 changes: 5 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
FROM node:16

ENV NODE_ENV=production

WORKDIR /app
COPY package*.json /app/

RUN npm install
RUN npm set-script prepare "" && \
npm ci --omit=dev --no-audit --only=production --verbose

COPY build ./
COPY entrypoint.sh ./

ENTRYPOINT [ "/app/entrypoint.sh" ]
CMD [ "wait" ]

8 changes: 8 additions & 0 deletions Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM node:16

ENV NODE_ENV=dev
WORKDIR /app
VOLUME /app

ENTRYPOINT [ "/app/entrypoint.sh" ]
CMD [ "wait" ]
15 changes: 15 additions & 0 deletions Dockerfile.production
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM node:16

ENV NODE_ENV=production

WORKDIR /app
COPY package*.json /app/

RUN npm set-script prepare "" && \
npm ci --omit=dev --no-audit --only=production --verbose

COPY build ./
COPY entrypoint.sh ./

ENTRYPOINT [ "/app/entrypoint.sh" ]
CMD [ "wait" ]
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
# Introdução
# Introduction

Template para projetos em typescript
Server websocket

## Development

## Desenvolvimento
### Prerequisites

### Pre-requisitos
To use this project, you will need the following software installed:

Para utilizar este projeto você precisará ter os seguintes softwares instalados:
- Node.js version 16.x (specific);
- VSCode or Neovim.

- Docker 19.x ou superior;
- Nodejs versão 16.x (especifica);
- VSCode ou Neovim;
### Environment

### Ambiente

Para inicializar o ambiente de desenvolvimento, utilize:
To initialize the development environment, use:

```sh
npm install
npm start
npm run dev
```

### force push
23 changes: 18 additions & 5 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,24 @@
#!/bin/sh

if [ "x$@" = "xwait" ] ; then
while true ; do
date
node index.js
sleep 300
done
if [ "x$RABBITMQ_PORT" = "x" ] ; then
export RABBITMQ_PORT=5672
fi
if [ "x$RABBITMQ_HOST" = "x" ] ; then
echo RABBITMQ_HOST não definido
else
node tools/wait.js $RABBITMQ_HOST $RABBITMQ_PORT
fi
if [ "x$NODE_ENV" = "xproduction" ] ; then
while true ; do
date
npm start
sleep 300
done
else
echo NODE_ENV já definido: $NODE_ENV
npm run $NODE_ENV
fi
else
echo Executando comando: $@
$@
Expand Down
Loading

0 comments on commit c41a2c5

Please sign in to comment.