Skip to content

Commit

Permalink
Merge pull request #192 from dadosjusbr/github-workflow
Browse files Browse the repository at this point in the history
feat: github workflows and dockerfile
  • Loading branch information
duardoqueiroz authored Aug 31, 2022
2 parents 7fa50fc + 654edff commit e4742f9
Show file tree
Hide file tree
Showing 4 changed files with 114 additions and 1 deletion.
61 changes: 61 additions & 0 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Docker

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

on:
#schedule:
# - cron: '22 13 * * *'
push:
branches: [main]
# Publish semver tags as releases.
tags: ['v*.*.*']
#pull_request:
# branches: [ main ]

env:
# Use docker.io for Docker Hub if empty
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
IMAGE_NAME: ${{ github.repository }}

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

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

# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@v1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v3
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

# Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
- name: Build and push Docker image
uses: docker/build-push-action@v2
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
17 changes: 17 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM node:16

WORKDIR /app

COPY ./package*.json ./

RUN yarn

COPY . .

ENV DEFAULT_API_BASE_URL=$DEFAULT_API_BASE_URL \
API_BASE_URL=$API_BASE_URL \
PACKAGE_REPO_URL=$PACKAGE_REPO_URL \
ID_ANALYTICS=$ID_ANALYTICS

CMD ["yarn","dev"]

24 changes: 23 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,29 @@ Essa aplicação foi feita utilizando o next js [Next.js](https://nextjs.org/) o
- [`styled-components`](https://styled-components.com/)
- [`eslint`](https://eslint.org/)

## Como rodar localmente
## Rodando localmente com Docker

Antes de mais nada, é necessário ter o [Docker](https://www.docker.com/get-started/) e o [Docker compose](https://docs.docker.com/compose/install/) instalados na sua máquina.

Crie uma cópia do arquivo `.env.sample` e renomeie para `.env.local` e configure as variáveis devidamente, caso necessário.

Rodando o servidor de desenvolvimento.

```bash
docker-compose --env-file .env.local up -d
```

Para checar se ocorreu tudo bem ao executar o docker-compose, rode o seguinte comando:

```bash
docker-compose logs
```

Caso tenha ocorrido tudo bem, entre no endereço [http://localhost:3000](http://localhost:3000) no seu navegador para ver o resultado.

## Como rodar localmente sem Docker)

Para conseguir rodar o servidor de desenvolvimento, sem utilização de Docker, é necessário ter o [Node.js](https://nodejs.org/pt-br/) instalado na sua máquina; ele é um runtime de JavaScript, necessário para executar nosso script.

Crie uma cópia do arquivo `.env.sample` e renomeie para `.env.local` e configure as variáveis devidamente, caso necessário.

Expand Down
13 changes: 13 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
version: '3'
services:
site:
build:
dockerfile: ./Dockerfile
context: '.'
environment:
- DEFAULT_API_BASE_URL= ${DEFAULT_API_BASE_URL}
- API_BASE_URL= ${API_BASE_URL}
- PACKAGE_REPO_URL= ${PACKAGE_REPO_URL}
- ID_ANALYTICS= ${ID_ANALYTICS}
ports:
- 3000:3000

0 comments on commit e4742f9

Please sign in to comment.