Skip to content

Commit

Permalink
try
Browse files Browse the repository at this point in the history
Signed-off-by: MatheusVict <[email protected]>
  • Loading branch information
MatheusVict committed Apr 23, 2024
1 parent 9f18ae8 commit 729f692
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
dist
.env
42 changes: 42 additions & 0 deletions .github/workflows/build_and_push_image_to_docker_hub.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Build and Push Docker Image

on:
push:
branches:
- main
- develop

jobs:
build-and-push:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Log in to Docker hub
uses: docker/[email protected]
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: 18

- name: Install dependencies
run: npm install

- name: Build Docker image
run: docker build -t ${{ secrets.DOCKER_USERNAME }}/go_lembrar_server .

- name: Tag Docker image
run:|
docker tag ${{ secrets.DOCKER_USERNAME }}/go_lembrar_server ${{ secrets.DOCKER_USERNAME }}/go_lembrar_server:latest
docker tag ${{ secrets.DOCKER_USERNAME }}/go_lembrar_server ${{ secrets.DOCKER_USERNAME }}/go_lembrar_server:${{ github.run_id }}

- name: Push Docker image
run: |
docker push ${{ secrets.DOCKER_USERNAME }}/go_lembrar_server:${{ github.run_id }}
docker push ${{ secrets.DOCKER_USERNAME }}/go_lembrar_server:latest
17 changes: 17 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM node:18

WORKDIR /usr/src/app

COPY . .

COPY ./.env.example ./env

COPY package*.json ./

RUN npm install

RUN npm run build



CMD [ "npm", "run", "start:prod" ]
25 changes: 24 additions & 1 deletion compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,27 @@ services:
- POSTGRESQL_PASSWORD=test
- POSTGRESQL_DATABASE=golembrar
volumes:
- ./.docker/db/data:/var/lib/postgresql/:delegated
- ./.docker/db/data:/var/lib/postgresql/:delegated
healthcheck:
test: [ "CMD-SHELL", "psql -h localhost -U admin -d rinha -c 'SELECT 1;'" ]
interval: 5s
timeout: 5s
retries: 20
start_period: 10s

api:
depends_on:
db:
condition: service_healthy
build: .
environment:
- DATABASE_URL="postgresql://test:test@db:5432/golembrar?schema=publicvalue"
- JWT_SECRET="variosnumerosletrasesimbolosmisturadosparasegurançadosecret"
- JWT_EXP="1h"
ports:
- "3000:3000"

networks:
default:
driver: bridge
name: golembrar

0 comments on commit 729f692

Please sign in to comment.