Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/merge backend frontend #5

Merged
merged 4 commits into from
Apr 12, 2022
Merged
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
46 changes: 12 additions & 34 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,34 +1,12 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# 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
.env.development.local
.env.test.local
.env.production.local

# vercel
.vercel
# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Postgresql stuffs
pg_data/
pg_backups/
45 changes: 7 additions & 38 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,48 +1,17 @@
# PZ Server

The Photo-z (PZ) Server is one of the Brazilian in-kind contributions offered by the Laboratório Interinstitucional de e-Astronomia (LIneA) to the PZ Coordination Group from Vera C. Rubin Observatory's Data Management (DM) Team. Inspired by features of the DES Science Portal (Gschwend et al., 2018; Fausti Neto et al., 2018), the PZ Server is being planned to be an online service, complementary to the Rubin Science Platform (RSP), to host PZ-related lightweight data products and to offer data management tools that allow sharing data products among RSP users, attach and share relevant metadata, and help on provenance tracking.

---
###

## Development
### Dependencies
- [NodeJS](https://nodejs.org/en/download/)
- [Yarn](https://classic.yarnpkg.com/lang/en/docs/install/#debian-stable)
### Setup Database

First, install the dependencies:
```bash
yarn install
```
Inicie o serviço do banco de dados e espere a mensagem `database system is ready to accept connections` para só depois iniciar o backend.

After, run the development server:
```bash
yarn dev
```

Finally, open [http://localhost:3000](http://localhost:3000) with your browser.

---

## Production
### Dependencies
- [Docker](https://docs.docker.com/engine/install/)
- [Docker Compose](https://docs.docker.com/compose/install/)

Build the application's image:
```bash
docker-compose build
```

In case you want to use an already built image, change the name in [docker-compose.yml](docker-compose.yml):
```
...
services:
frontend:
image: CHANGE_IMAGE_NAME
...
docker-compose up database
```

Run the application:
### Setup Frontend
Antes de iniciar o container do frontend é necessário instalar as dependencias do react.
```bash
docker-compose up
docker-compose run frontend yarn
```
4 changes: 4 additions & 0 deletions archive/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
*
*/
!.gitignore
!django_static
4 changes: 4 additions & 0 deletions archive/django_static/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
*
*/
!.gitignore

160 changes: 160 additions & 0 deletions backend/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock

# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/#use-with-ide
.pdm.toml

# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
44 changes: 44 additions & 0 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
FROM python:3.10-slim as builder

WORKDIR /app

# If this is set to a non-empty string, Python won’t try
# to write .pyc files on the import of source modules
ENV PYTHONDONTWRITEBYTECODE=1

# Force the stdout and stderr streams to be unbuffered.
# This option has no effect on the stdin stream.
ENV PYTHONUNBUFFERED=1

# TODO: Instalar as dependencias do LDAP e do Shibboleth.
RUN apt-get update && \
apt-get install -y --no-install-recommends \
gcc \
python3-dev \
build-essential \
libpcre3 \
libpcre3-dev

RUN python -m venv /opt/venv

ENV PATH="/opt/venv/bin:$PATH"

COPY requirements.txt .

RUN pip install --upgrade pip wheel && \
pip install -r requirements.txt


FROM python:3.10-slim

COPY --from=builder /opt/venv /opt/venv

WORKDIR /app

ENV PATH="/opt/venv/bin:$PATH"

COPY ./entrypoint.sh /app/entrypoint.sh
ENTRYPOINT ./entrypoint.sh

COPY . /app

17 changes: 17 additions & 0 deletions backend/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Pz Server API
First version of Pz Server data access API for LSST

## Requirements
- docker
- docker-compose

## Getting Started

```bash
docker-compose up -d
```

Open http://localhost with your browser to see the result.

## License
[MIT](LICENSE)
21 changes: 21 additions & 0 deletions backend/app/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2022 LIneA IT

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Empty file added backend/app/core/__init__.py
Empty file.
6 changes: 6 additions & 0 deletions backend/app/core/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.contrib import admin
from core.models import ProductType, Product, Release

admin.site.register(ProductType)
admin.site.register(Release)
admin.site.register(Product)
21 changes: 21 additions & 0 deletions backend/app/core/api/serializers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from rest_framework import serializers
from core import models


class ProductTypeSerializer(serializers.ModelSerializer):
class Meta:
model = models.ProductType
fields = "__all__"


class ReleaseSerializer(serializers.ModelSerializer):
class Meta:
model = models.Release
fields = "__all__"


class ProductSerializer(serializers.ModelSerializer):
class Meta:
model = models.Product
fields = "__all__"
read_only_fields = ("file_size", "file_extension", "file_name",)
Loading