Skip to content

Commit

Permalink
Merge pull request #12 from linea-it/4-install-reactjs
Browse files Browse the repository at this point in the history
4 install reactjs
  • Loading branch information
glaubervila authored Sep 10, 2024
2 parents 257ca1e + c7d2307 commit 3b0c0f8
Show file tree
Hide file tree
Showing 31 changed files with 8,519 additions and 90 deletions.
150 changes: 79 additions & 71 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,76 +1,84 @@
// For format details, see https://containers.dev/implementors/json_reference/
{
"name": "sky_viewer_dev",
"dockerComposeFile": [
"../docker-compose.local.yml",
"docker-compose.yml"
],
"init": true,
"mounts": [
{
"source": "./.devcontainer/bash_history",
"target": "/home/dev-user/.bash_history",
"type": "bind"
"name": "sky_viewer_dev",
"dockerComposeFile": [
"../docker-compose.local.yml",
"docker-compose.yml"
],
"init": true,
"mounts": [
{
"source": "./.devcontainer/bash_history",
"target": "/home/dev-user/.bash_history",
"type": "bind"
},
{
"source": "~/.ssh",
"target": "/home/dev-user/.ssh",
"type": "bind"
},
{
"source": "..",
"target": "/workspaces",
"type": "bind"
}
],
// Tells devcontainer.json supporting services / tools whether they should run
// /bin/sh -c "while sleep 1000; do :; done" when starting the container instead of the container’s default command
"overrideCommand": false,
"service": "vscode",
// "remoteEnv": {"PATH": "/home/dev-user/.local/bin:${containerEnv:PATH}"},
// "remoteUser": "dev-user",
// The optional 'workspaceFolder' property is the path VS Code should open by default when
// connected. This is typically a file mount in .devcontainer/docker-compose.yml
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",
// Set *default* container specific settings.json values on container create.
// Features to add to the dev container. More info: https://containers.dev/features.
"features": {
"ghcr.io/devcontainers/features/node:1": {},
"ghcr.io/devcontainers/features/github-cli:1": {}
},
"customizations": {
"vscode": {
"settings": {
"editor.formatOnSave": true,
"[python]": {
"analysis.autoImportCompletions": true,
"analysis.typeCheckingMode": "basic",
"defaultInterpreterPath": "/usr/local/bin/python",
"editor.codeActionsOnSave": {
"source.organizeImports": "always"
},
"editor.defaultFormatter": "charliermarsh.ruff",
"languageServer": "Pylance",
"linting.enabled": true,
"linting.mypyEnabled": true,
"linting.mypyPath": "/usr/local/bin/mypy",
},
{
"source": "~/.ssh",
"target": "/home/dev-user/.ssh",
"type": "bind"
"[javascript]": {
"editor.tabSize": 2
},
{
"source": "..",
"target": "/workspaces",
"type": "bind"
}
],
// Tells devcontainer.json supporting services / tools whether they should run
// /bin/sh -c "while sleep 1000; do :; done" when starting the container instead of the container’s default command
"overrideCommand": false,
"service": "vscode",
// "remoteEnv": {"PATH": "/home/dev-user/.local/bin:${containerEnv:PATH}"},
// "remoteUser": "dev-user",
// The optional 'workspaceFolder' property is the path VS Code should open by default when
// connected. This is typically a file mount in .devcontainer/docker-compose.yml
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",
// Set *default* container specific settings.json values on container create.
"customizations": {
"vscode": {
"settings": {
"editor.formatOnSave": true,
"[python]": {
"analysis.autoImportCompletions": true,
"analysis.typeCheckingMode": "basic",
"defaultInterpreterPath": "/usr/local/bin/python",
"editor.codeActionsOnSave": {
"source.organizeImports": "always"
},
"editor.defaultFormatter": "charliermarsh.ruff",
"languageServer": "Pylance",
"linting.enabled": true,
"linting.mypyEnabled": true,
"linting.mypyPath": "/usr/local/bin/mypy",
}
},
// https://code.visualstudio.com/docs/remote/devcontainerjson-reference#_vs-code-specific-properties
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"davidanson.vscode-markdownlint",
"mrmlnc.vscode-duplicate",
"visualstudioexptteam.vscodeintellicode",
"visualstudioexptteam.intellicode-api-usage-examples",
// python
"ms-python.python",
"ms-python.vscode-pylance",
"charliermarsh.ruff",
// django
"batisteo.vscode-django"
]
}
},
// Uncomment the next line if you want start specific services in your Docker Compose config.
// "runServices": [],
// Uncomment the next line if you want to keep your containers running after VS Code shuts down.
// "shutdownAction": "none",
// Uncomment the next line to run commands after the container is created.
"postCreateCommand": "cat .devcontainer/bashrc.override.sh >> ~/.bashrc"
},
// https://code.visualstudio.com/docs/remote/devcontainerjson-reference#_vs-code-specific-properties
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"davidanson.vscode-markdownlint",
"mrmlnc.vscode-duplicate",
"visualstudioexptteam.vscodeintellicode",
"visualstudioexptteam.intellicode-api-usage-examples",
// python
"ms-python.python",
"ms-python.vscode-pylance",
"charliermarsh.ruff",
// django
"batisteo.vscode-django"
]
}
},
// Uncomment the next line if you want start specific services in your Docker Compose config.
// "runServices": [],
// Uncomment the next line if you want to keep your containers running after VS Code shuts down.
// "shutdownAction": "none",
// Uncomment the next line to run commands after the container is created.
"postCreateCommand": "cat .devcontainer/bashrc.override.sh >> ~/.bashrc"
}
10 changes: 10 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,16 @@ repos:
- id: djlint-reformat-django
- id: djlint-django

- repo: https://github.com/pre-commit/mirrors-eslint
rev: v8.56.0
hooks:
- id: eslint
name: Eslint
entry: bash -c 'cd frontend && npm run lint'
additional_dependencies:
- [email protected]
- [email protected]

# sets up .pre-commit-ci.yaml to ensure pre-commit dependencies stay up to date
ci:
autoupdate_schedule: weekly
Expand Down
2 changes: 1 addition & 1 deletion backend/config/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@
# https://docs.djangoproject.com/en/dev/ref/settings/#static-root
STATIC_ROOT = str(BASE_DIR / "staticfiles")
# https://docs.djangoproject.com/en/dev/ref/settings/#static-url
STATIC_URL = "/static/"
STATIC_URL = "/django_static/"
# https://docs.djangoproject.com/en/dev/ref/contrib/staticfiles/#std:setting-STATICFILES_DIRS
STATICFILES_DIRS = [str(APPS_DIR / "static")]
# https://docs.djangoproject.com/en/dev/ref/contrib/staticfiles/#staticfiles-finders
Expand Down
2 changes: 1 addition & 1 deletion backend/config/settings/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
default="nFK0g6mvH2IjeawVrOykaac3UD9hRLJoWzmlnWiDlJM1joaFM4KUQWiGZPad7pRc",
)
# https://docs.djangoproject.com/en/dev/ref/settings/#allowed-hosts
ALLOWED_HOSTS = ["localhost", "0.0.0.0", "127.0.0.1"] # noqa: S104
ALLOWED_HOSTS = ["localhost", "0.0.0.0", "127.0.0.1", "srvapi"] # noqa: S104

# CACHES
# ------------------------------------------------------------------------------
Expand Down
16 changes: 8 additions & 8 deletions backend/config/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@
from rest_framework.authtoken.views import obtain_auth_token

urlpatterns = [
path("", TemplateView.as_view(template_name="pages/home.html"), name="home"),
path(
"about/",
TemplateView.as_view(template_name="pages/about.html"),
name="about",
),
# path("", TemplateView.as_view(template_name="pages/home.html"), name="home"),
# path(
# "about/",
# TemplateView.as_view(template_name="pages/about.html"),
# name="about",
# ),
# Django Admin, use {% url 'admin:index' %}
path(settings.ADMIN_URL, admin.site.urls),
# User management
path("users/", include("sky_viewer.users.urls", namespace="users")),
path("accounts/", include("allauth.urls")),
# path("users/", include("sky_viewer.users.urls", namespace="users")),
# path("accounts/", include("allauth.urls")),
# Your stuff: custom urls includes go here
# ...
# Media files
Expand Down
2 changes: 1 addition & 1 deletion compose/local/django/celery/flower/start
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ echo 'Starting flower'

exec watchfiles --filter python celery.__main__.main \
--args \
"-A config.celery_app -b \"${CELERY_BROKER_URL}\" flower --basic_auth=\"${CELERY_FLOWER_USER}:${CELERY_FLOWER_PASSWORD}\""
"-A config.celery_app -b \"${CELERY_BROKER_URL}\" flower --basic_auth=\"${CELERY_FLOWER_USER}:${CELERY_FLOWER_PASSWORD}\" --url-prefix=flower"
18 changes: 18 additions & 0 deletions compose/production/react/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM node:22.7.0-bookworm-slim AS base

ENV GENERATE_SOURCEMAP=false
ENV NODE_OPTIONS=--max_old_space_size=8192

COPY ./compose/local/react/start /start
RUN sed -i 's/\r$//g' /start
RUN chmod +x /start

RUN mkdir /app && chown -R node:node /app

COPY ./frontend /app
WORKDIR /app

USER node

RUN yarn -v
RUN yarn --non-interactive --ignore-optional --network-timeout 500000
7 changes: 7 additions & 0 deletions compose/production/react/start
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

set -o errexit
set -o pipefail
set -o nounset

yarn dev
37 changes: 29 additions & 8 deletions docker-compose.local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ volumes:
sky_viewer_local_redis_data: {}

services:
django: &django
backend: &backend
build:
context: ./
dockerfile: ./compose/local/django/Dockerfile
image: sky_viewer_local_django
container_name: sky_viewer_local_django
container_name: sky_viewer_local_backend
depends_on:
- postgres
- redis
Expand All @@ -19,10 +19,17 @@ services:
env_file:
- ./.envs/.local/.django
- ./.envs/.local/.postgres
ports:
- '80:8000'
command: /start

frontend:
image: node:22.7.0-bookworm-slim
container_name: sky_viewer_local_react
user: 1000:1000
working_dir: /app
volumes:
- ./frontend:/app:z
command: yarn dev

postgres:
build:
context: .
Expand All @@ -35,21 +42,35 @@ services:
env_file:
- ./.envs/.local/.postgres

nginx:
image: nginx:latest
ports:
- ${PORT:-80}:80
volumes:
# Arquivo de configuração do Ngnix para este ambiente.
- ${PROJ_DIR:-.}/nginx-proxy.conf:/etc/nginx/conf.d/default.conf:ro
depends_on:
- backend
- frontend
- flower
- mailpit

mailpit:
image: docker.io/axllent/mailpit:latest
container_name: sky_viewer_local_mailpit
environment:
- MP_WEBROOT=/mailpit/
ports:
- "8025:8025"

redis:
image: docker.io/redis:6
container_name: sky_viewer_local_redis

volumes:
- sky_viewer_local_redis_data:/data

celeryworker:
<<: *django
<<: *backend
image: sky_viewer_local_celeryworker
container_name: sky_viewer_local_celeryworker
depends_on:
Expand All @@ -60,7 +81,7 @@ services:
command: /start-celeryworker

celerybeat:
<<: *django
<<: *backend
image: sky_viewer_local_celerybeat
container_name: sky_viewer_local_celerybeat
depends_on:
Expand All @@ -71,7 +92,7 @@ services:
command: /start-celerybeat

flower:
<<: *django
<<: *backend
image: sky_viewer_local_flower
container_name: sky_viewer_local_flower
ports:
Expand Down
3 changes: 3 additions & 0 deletions frontend/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "next/core-web-vitals"
}
36 changes: 36 additions & 0 deletions frontend/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js
.yarn/install-state.gz

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# local env files
.env*.local

# vercel
.vercel

# typescript
*.tsbuildinfo
next-env.d.ts
Loading

0 comments on commit 3b0c0f8

Please sign in to comment.