Skip to content
This repository has been archived by the owner on Nov 7, 2024. It is now read-only.

Entrega - Pedro Vietro #100

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .credo.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
%{
configs: [
%{
name: "default",
files: %{
included: ["lib/", "src/", "web/", "apps/"],
excluded: ["deps/"]
},
plugins: [],
requires: [],
strict: false,
parse_timeout: 5000,
color: true,
checks: [
{Credo.Check.Design.DuplicatedCode},
{Credo.Check.Readability.FunctionNames},
{Credo.Check.Warning.MapGetUnsafePass},
{Credo.Check.Design.TagTODO, false},
{Credo.Check.Warning.OperationOnSameValues, priority: :normal}
]
}
]
}
18 changes: 18 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
.dockerignore
# there are valid reasons to keep the .git, namely so that you can get the
# current commit hash
#.git
.log
tmp

# Mix artifacts
_build
deps
*.ez
releases

# Generate on crash by the VM
erl_crash.dump

# Static artifacts
node_modules
5 changes: 5 additions & 0 deletions .formatter.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[
import_deps: [:ecto, :phoenix],
inputs: ["*.{ex,exs}", "priv/*/seeds.exs", "{config,lib,test}/**/*.{ex,exs}"],
subdirectories: ["priv/*/migrations"]
]
64 changes: 64 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# The directory Mix will write compiled artifacts to.
/_build/

# If you run "mix test --cover", coverage assets end up here.
/cover/

# The directory Mix downloads your dependencies sources to.
/deps/

# Where 3rd-party dependencies like ExDoc output generated docs.
/doc/

# Ignore .fetch files in case you like to edit your project deps locally.
/.fetch

# If the VM crashes, it generates a dump, let's ignore it too.
erl_crash.dump

# Also ignore archive artifacts (built via "mix archive.build").
*.ez

# Ignore package tarball (built via "mix hex.build").
ateliware-*.tar

# Ignore assets that are produced by build tools.
/priv/static/assets/

# Ignore digested assets cache.
/priv/static/cache_manifest.json

# In case you use Node.js/npm, you want to ignore these.
npm-debug.log
/assets/node_modules/

/config/dev.exs


### TERRAFORM
# Local .terraform directories
**/.terraform/*

# .tfstate files
*.tfstate
*.tfstate.*

# Crash log files
crash.log
crash.*.log

# Exclude all .tfvars files, which are likely to contain sentitive data, such as
# password, private keys, and other secrets. These should not be part of version
# control as they are data points which are potentially sensitive and subject
# to change depending on the environment.
#
**/*.tfvars
!**/sample.tfvars

# Ignore override files as they are usually used to override resources locally and so
# are not checked in
override.tf
override.tf.json
*_override.tf
*_override.tf.json

83 changes: 83 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# ENV VARIABLES:
# DATABASE_URL: example: `ecto://postgres:postgres@localhost/ateliware_prod`
# SECRET_KEY_BASE: example `+iB4Srfgmw8c63O3jfBJ6L5k6A0bezf/PexYT53vUxUM+yXb+Wkn6/d+huleQEEZ`
# DB_HOST: example `localhost`
# DB_USER: example `postgres`

ARG BUILDER_IMAGE="hexpm/elixir:1.13.0-erlang-24.2-debian-bullseye-20210902-slim"
ARG RUNNER_IMAGE="debian:bullseye-20210902-slim"

FROM ${BUILDER_IMAGE} as builder

# install build dependencies
RUN apt-get update -y && apt-get install -y build-essential git \
&& apt-get clean && rm -f /var/lib/apt/lists/*_*

# prepare build dir
WORKDIR /app

# install hex + rebar
RUN mix local.hex --force && \
mix local.rebar --force

# set build ENV
ENV MIX_ENV="prod"

# install mix dependencies
COPY mix.exs mix.lock ./
RUN mix deps.get --only $MIX_ENV
RUN mkdir config

# copy compile-time config files before we compile dependencies
# to ensure any relevant config change will trigger the dependencies
# to be re-compiled.
COPY config/config.exs config/${MIX_ENV}.exs config/
RUN mix deps.compile

COPY priv priv

# note: if your project uses a tool like https://purgecss.com/,
# which customizes asset compilation based on what it finds in
# your Elixir templates, you will need to move the asset compilation
# step down so that `lib` is available.

# Compile the release
COPY lib lib

COPY assets assets

# compile assets
RUN mix assets.deploy

RUN mix compile

# Changes to config/runtime.exs don't require recompiling the code
COPY config/runtime.exs config/

COPY rel rel
RUN mix release

# start a new build stage so that the final image will only contain
# the compiled release and other runtime necessities
FROM ${RUNNER_IMAGE}

RUN apt-get update -y && apt-get install -y libstdc++6 openssl libncurses5 locales postgresql-client \
&& apt-get clean && rm -f /var/lib/apt/lists/*_*

# Set the locale
RUN sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen && locale-gen

ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8

WORKDIR "/app"
RUN chown nobody /app

# Only copy the final release from the build stage
COPY --from=builder --chown=nobody:root /app/_build/prod/rel/ateliware ./
COPY entrypoint.sh .

USER nobody

CMD ["bash", "/app/entrypoint.sh"]
119 changes: 103 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,109 @@
# Desafio técnico para desenvolvedores
<h1 align="center">
Ateliware Challenge
</h1>

Construa uma nova aplicação, utilizando o framework de sua preferência (Ruby on Rails, Elixir Phoenix, Python Django ou Flask, NodeJS Sails, Java Spring, ASP.NET ou outro), a qual deverá conectar na API do GitHub e disponibilizar as seguintes funcionalidades:
<p align="center">
<a href="#projeto">Projeto</a> •
<a href="#homepage">Homepage</a> •
<a href="#como-executar">Como executar</a> •
<a href="#tecnologias">Tecnologias</a>
</p>

- Botão para buscar e armazenar os repositórios destaques de 5 linguagens à sua escolha;
- Listar os repositórios encontrados;
- Visualizar os detalhes de cada repositório.
## Projeto

Alguns requisitos:
Esta é uma aplicação proposta pela [Ateliware](https://ateliware.com/) para armazenar os repositórios destaques de 5 linguagens diferentes.

- Deve ser uma aplicação totalmente nova;
- A solução deve estar em um repositório público do GitHub;
- A aplicação deve armazenar as informações encontradas;
- Utilizar PostgreSQL, MySQL ou SQL Server;
- O deploy deve ser realizado, preferencialmente, no Heroku, AWS ou no Azure;
- A aplicação precisa ter testes automatizados;
- Preferenciamente dockerizar a aplicação;
- Por favor atualizar o readme da aplicação com passo a passo com instrução para subir o ambiente.
Você pode acessar uma live preview [aqui](http://54.207.96.203/) _deploy feito na aws usando terraform e docker-compose_

Quando terminar, faça um Pull Request neste repo e avise-nos por email.
<br>

**IMPORTANTE:** se você não conseguir finalizar o teste, por favor nos diga o motivo e descreva quais foram as suas dificuldades. Você pode também sugerir uma outra abordagem para avaliarmos seus skills técnicos, vender seu peixe, mostrar-nos do que é capaz.
## Homepage
![](https://i.postimg.cc/02kX2xgt/image.png)

![](https://i.postimg.cc/66nT5JVG/image.png)


## Como executar
<br>

### Local
Configurando o ambiente local:

Necessário:

* `elixir`
* `mix`

```bash
#!/bin/bash

# copie a configuração base de desenvolvimento
cp config/sample.dev.exs config/dev.exs
# após isso, adicione suas credenciais do banco de dados
mix tailwind.install
mix tailwind.default
mix deps.get
mix ecto.setup

# após isso você pode rodar testes com
# para isso é necessario inserir suas credenciais do banco de dados em config/test.exs
mix test

# e rodar o servidor com
mix phx.server

```
o servidor estará disponível em http://localhost:4000

<br>

### Docker Compose

Necessário:

* `docker`
* `docker-compose`

```bash
docker-compose up -d
```
O servidor e o banco serão executados e estará ouvindo em [localhost](http://localhost)

<br>

### IaC - Infrastructure as Code

Para fazer um deploy na AWS utilizando Terraform

Necessário:

* `cli-aws` <b>autenticado</b>
* `terraform`

```bash
#!/bin/bash
cd terraform

cp sample.tfvars terraform.tfvars

# preencha o arquivo criado com as credenciais necessarias
terraform init

terraform apply

# revise as alterações que serão feitas e digite 'yes' caso decida prosseguir

```

## Tecnologias
* Elixir
* Phoenix
* Phoenix Live View
* TailwindCSS
* Postgres
* Docker
* Docker Compose
* Terraform
* AWS EC2

<br> <br>
63 changes: 63 additions & 0 deletions assets/css/app.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@200;400;700&display=swap');

@tailwind base;
@tailwind components;
@tailwind utilities;

@layer components{
.fade-in { animation: fadeIn 0.2s 1 linear; }
.fade-out { animation: fadeOut 0.2s 1 linear; }

.collapse-close { animation: collapseClose 0.2s 1 linear; transform: rotate(270deg); }
.collapse-open { animation: collapseOpen 0.2s 1 linear; }

.loader {
border-right-color: transparent;
animation: loader-rotate 1s linear infinite;
}
@keyframes loader-rotate {
0% {
transform: rotate(0);
}
100% {
transform: rotate(360deg);
}
}


@keyframes fadeIn {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
@keyframes fadeOut {
from {
opacity: 1;
}
to {
opacity: 0;
}
}


@keyframes collapseClose {
from {
transform: rotate(0);
}
to {
transform: rotate(270deg);
}
}

@keyframes collapseOpen {
from {
transform: rotate(270deg);
}
to {
transform: rotate(0);
}
}
}
Loading