Skip to content
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
73 changes: 73 additions & 0 deletions .github/workflows/deploy-document.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# Workflow for deploying Sphinx documentation built within a Docker container to GitHub Pages
name: Deploy Sphinx Document to Pages

on:
# Runs on pushes targeting the default branch
push:
branches: ["main"]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# Set permissions for the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

# Allow only one concurrent deployment, skipping queued runs, but do not cancel in-progress ones
concurrency:
group: "pages"
cancel-in-progress: false

jobs:
# Single deploy job since we're just deploying
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest

steps:
# Step 1: Checkout the repository
- uses: actions/checkout@v3

# Step 2: Install Docker Compose
- name: Install Docker Compose
run: |
sudo apt-get update
sudo apt-get install -y docker-compose

# Step 3: Create an .env file if required
- name: Make .env file
run: |
if [ -f .env.example ]; then
cp .env.example .env
fi

# Step 4: Build and Start the containers
- name: Build and Start Docker Containers
run: |
docker-compose -f docker-compose.yml --env-file .env up --build -d

# Step 5: Run commands inside the Docker container to build Sphinx documentation
- name: Build Sphinx Documentation inside Container
run: |
docker-compose -f docker-compose.yml --env-file .env exec -T dev bash -c "
cd docs && \
poetry run make dirhtml"

# Step 6: Set up Pages configuration for deployment
- name: Setup Pages
uses: actions/configure-pages@v3

# Step 7: Upload the generated HTML files as artifacts for deployment
- name: Upload artifact
uses: actions/upload-pages-artifact@v2
with:
path: "./docs/build"

# Step 8: Deploy to GitHub Pages
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v2
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ __pycache__/

# output
.DS_Store

# Sphinx documentation
docs/build/**
11 changes: 8 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ FROM ubuntu:22.04

ENV LANG=C.UTF-8 \
LANGUAGE=en_US \
PYTHONPATH="/root/workspace:$PYTHONPATH" \
DEBIAN_FRONTEND=noninteractive
PYTHONPATH="/root/workspace/src:$PYTHONPATH" \
DEBIAN_FRONTEND=noninteractive \
TZ=Asia/Tokyo

# Pythonのインストール
RUN apt-get update && apt-get install -y python3.10 python3-pip \
Expand All @@ -15,11 +16,11 @@ RUN apt-get update && apt-get install -y \
libgl1-mesa-glx \
&& rm -rf /var/lib/apt/lists/*

# jupyter notebookの設定
# pipをアップグレードし、必要なパッケージをインストール
RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir notebook==6.4.6 jupyter_contrib_nbextensions jupyter_nbextensions_configurator

# jupyter notebookの設定
## Jupyterのnbextensionsをインストールし、nbextensions_configuratorを有効化
RUN jupyter contrib nbextension install --system && \
jupyter nbextensions_configurator enable --system
Expand Down Expand Up @@ -49,3 +50,7 @@ RUN poetry install --no-root

# Jupyter notebookの設定
RUN python -m ipykernel install --user --name python3.10 --display-name "Python 3.10"

# Clear cache to free up space
RUN apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
48 changes: 8 additions & 40 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,44 +1,12 @@
# python
# python-template

| | |
| --------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **License** | ![LICENSE](https://img.shields.io/badge/license-MIT-blue.svg?style=flat) |
| **Environment** | ![Ubuntu](https://img.shields.io/badge/-Ubuntu_22.04_LTS-fad9c1.svg?logo=ubuntu&style=flat) <br> ![Docker](https://img.shields.io/badge/-Docker_v26.0.2-0055a4.svg?logo=docker&style=flat) ![Docker Compose](https://img.shields.io/badge/-Docker_Compose_v2.22.0-0055a4.svg?logo=docker&style=flat) <br> ![Python](https://img.shields.io/badge/-Python_3.10-F9DC3E.svg?logo=python&style=flat) ![Poetry](https://img.shields.io/badge/-Poetry-2c2d72.svg?logo=python&style=flat) |
| **Technology** | |
| |
This is a template repository for Python projects.

## Requirements
| | |
| --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| **License** | ![LICENSE](https://img.shields.io/badge/license-MIT-blue.svg?style=flat) |
| **Environment** | ![Python](https://img.shields.io/badge/-Python_3.10-F9DC3E.svg?logo=python&style=flat) ![Poetry](https://img.shields.io/badge/-Poetry-2c2d72.svg?logo=python&style=flat) |

- Docker and docker-compose are required. The versions are as follows.
- Docker: v26.0.2
- Docker Compose: v2.22.0
## Documentation

## Getting Started

### 1. Clone Repository

```sh
$ git clone git@github.com:nglcobdai/python-template.git
$ cd python-template
```

### 2. Create .env file

- copy .env.example to .env

```sh
$ cp .env{.example,}
```

### 3. Docker Build & Run

```sh
$ docker-compose build --no-cache
$ docker-compose run --rm project
```

### 4. Run Python Script

```sh
$ python app/main.py
```
Refer to the [Official Documentation](https://nglcobdai.github.io/python-template/) for Installation, Quick Start, and API Reference.
9 changes: 0 additions & 9 deletions app/main.py

This file was deleted.

5 changes: 0 additions & 5 deletions app/utils/__init__.py

This file was deleted.

13 changes: 0 additions & 13 deletions app/utils/config.py

This file was deleted.

35 changes: 0 additions & 35 deletions app/utils/log.py

This file was deleted.

20 changes: 20 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = source
BUILDDIR = build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
47 changes: 47 additions & 0 deletions docs/make.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
@ECHO OFF

pushd %~dp0

REM Command file for Sphinx documentation

if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=source
set BUILDDIR=build

if "%1" == "" goto help

if "%1" == "preview" (
echo.Running sphinx-autobuild. View live edits at:
echo. http://0.0.0.0:8000
sphinx-autobuild -b html %SOURCEDIR% %BUILDDIR%/html
if errorlevel 1 exit /b 1
goto end
)

%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.http://sphinx-doc.org/
exit /b 1
)

:html
%SPHINXBUILD% -b html %SOURCEDIR% "docs" %SPHINXOPTS% %O%
goto end

%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
goto end

:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%

:end
popd
8 changes: 8 additions & 0 deletions docs/source/API/API.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
API
========================

.. toctree::
:maxdepth: 2

.. python_template.xxx

59 changes: 59 additions & 0 deletions docs/source/Development/Development.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
How to Development
==================

This document describes how to develop the this Library.

Environment
-----------

.. image:: https://img.shields.io/badge/-Ubuntu_22.04_LTS-fad9c1.svg?logo=ubuntu&style=flat

.. image:: https://img.shields.io/badge/-Docker_v26.0.2-0055a4.svg?logo=docker&style=flat

.. image:: https://img.shields.io/badge/-Docker_Compose_v2.22.0-0055a4.svg?logo=docker&style=flat

.. image:: https://img.shields.io/badge/-Python_3.10-F9DC3E.svg?logo=python&style=flat

.. image:: https://img.shields.io/badge/-Poetry-2c2d72.svg?logo=python&style=flat

Requirements
------------

- Docker and docker-compose are required. The versions are as follows.
- Docker: v26.0.2
- Docker Compose: v2.22.0

Getting Started
---------------

1. **Clone Repository**

.. code-block:: sh

$ git clone git@github.com:nglcobdai/python-template.git
$ cd python-template

2. **Create .env file**

- Copy ``.env.example`` to ``.env``

.. code-block:: sh

$ cp .env{.example,}

3. **Docker Build & Run**

.. code-block:: sh

$ docker-compose build --no-cache
$ docker-compose run --rm dev


Unit Test
---------

1. **Run Test**

.. code-block:: sh

$ pytest -v
Loading
Loading