From aada2553353159d0c244b4aa2ed4d59c9cab1f4e Mon Sep 17 00:00:00 2001 From: antonyg5 Date: Wed, 10 Aug 2022 08:33:23 -0300 Subject: [PATCH 1/2] feat: github workflows and dockerfile --- .github/workflows/docker-publish.yml | 61 ++++++++++++++++++++++++++++ Dockerfile | 17 ++++++++ 2 files changed, 78 insertions(+) create mode 100644 .github/workflows/docker-publish.yml create mode 100644 Dockerfile diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml new file mode 100644 index 00000000..92003f39 --- /dev/null +++ b/.github/workflows/docker-publish.yml @@ -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 / + 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 }} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..0ab3aab9 --- /dev/null +++ b/Dockerfile @@ -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"] + From 654edff5037ff6f595a551b61261c45b7c73fa67 Mon Sep 17 00:00:00 2001 From: duardoqueiroz Date: Mon, 15 Aug 2022 10:12:13 -0300 Subject: [PATCH 2/2] feat: docker-compose --- README.md | 24 +++++++++++++++++++++++- docker-compose.yml | 13 +++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 docker-compose.yml diff --git a/README.md b/README.md index 1c206530..53cfcaaf 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..58149efc --- /dev/null +++ b/docker-compose.yml @@ -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