Skip to content

Commit

Permalink
Merge pull request #146 from Jerakin/refactor/project-structure
Browse files Browse the repository at this point in the history
Project structure
  • Loading branch information
Linbreux authored Mar 6, 2024
2 parents 66aeb58 + d0f1c6a commit b87ae28
Show file tree
Hide file tree
Showing 75 changed files with 1,049 additions and 978 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
- name: Build & export
uses: docker/build-push-action@v3
with:
file: docker/Dockerfile
file: Dockerfile
push: false
tags: ${{ steps.meta.outputs.tags }}
outputs: type=docker,dest=/tmp/wikmd.tar
Expand Down Expand Up @@ -96,6 +96,10 @@ jobs:
- name: Assert wikmd status
run: curl -I localhost:5000 2>&1 | awk '/HTTP\// {print $2}' | grep -w "200\|301"

# Check that wikmd is rendering
- name: Check wikmd rendering status
run: curl -s localhost:5000 | grep -w "What is it?"

publish:
# Publish if official repo and push to 'main' or new tag
if: |
Expand All @@ -116,6 +120,6 @@ jobs:
- name: Publish
uses: docker/build-push-action@v3
with:
file: docker/Dockerfile
file: Dockerfile
push: true
tags: ${{ needs.build.outputs.wikmd_tags }}
11 changes: 6 additions & 5 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,16 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
pip install .[dev]
- name: Test with pytest
run: |
python -m pytest -v
python -m pytest
- name: Start wikmd
run: python wiki.py &

run: |
cd src
python -m wikmd.wiki &
- name: screenshots-ci-action
uses: flameddd/screenshots-ci-action@master
with:
Expand Down
13 changes: 5 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,12 @@ dmypy.json
# Cython debug symbols
cython_debug/

# Generated plugin files
src/wikmd/plugins/draw/drawings/*
!src/wikmd/plugins/draw/drawings/.gitkeep


# Personal wiki pages
wiki/*
wiki/src/*

!wiki/Features.md
!wiki/How to use the wiki.md
!wiki/Markdown cheatsheet.md
!wiki/Using the version control system.md
!wiki/homepage.md
!wiki/src

temp/*
6 changes: 1 addition & 5 deletions docker/README.md → DOCKER.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,14 @@

[wikmd](https://github.com/Linbreux/wikmd) is a file based wiki that uses markdown.

This repo provides Docker files that are loosely based on those of the [linuxserver](https://www.linuxserver.io/) community.

Docker files are available for arm, arm64 and amd64.

## Usage

Here are some example snippets to help you get started creating a container.

Build the image,

```bash
docker build -t linbreux/wikmd:latest -f docker/Dockerfile .
docker build -t linbreux/wikmd:latest -f Dockerfile .
```

### docker-compose (recommended, [click here for more info](https://docs.linuxserver.io/general/docker-compose))
Expand Down
66 changes: 66 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
FROM python:3.9-alpine3.17 as python-base

# Prevents Python from writing pyc files.
ENV PYTHONDONTWRITEBYTECODE=1

# Keeps Python from buffering stdout and stderr to avoid situations where
# the application crashes without emitting any logs due to buffering.
ENV PYTHONUNBUFFERED=1

# We will be installing venv
ENV VIRTUAL_ENV="/venv"

# Create a non-privileged user that the app will run under.
# See https://docs.docker.com/go/dockerfile-user-best-practices/
ARG UID=10001
RUN adduser \
--disabled-password \
--gecos "" \
--home "/nonexistent" \
--shell "/sbin/nologin" \
--no-create-home \
--uid "${UID}" \
appuser


# Add project path to python path, this to ensure we can reach it from anywhere
WORKDIR /code
ENV PYTHONPATH="/code:$PYTHONPATH"

# prepare the virtual env
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
RUN python -m venv $VIRTUAL_ENV

# BUILDER
FROM python-base as python-builder

# Install our dependencies
RUN apk update
RUN apk add git
RUN apk add pandoc
RUN apk add build-base linux-headers

# Python dependencies
WORKDIR /code

COPY pyproject.toml /code

# Copy the py project and use a package to convert our pyproject.toml file into a requirements file
# We can not install the pyproject with pip as that would install the project and we only
# wants to install the project dependencies.
RUN python -m pip install toml-to-requirements==0.2.0
RUN toml-to-req --toml-file pyproject.toml

RUN python -m pip install --no-cache-dir --upgrade -r ./requirements.txt

# Copy our source content over
COPY ./src/wikmd /code/wikmd

# Change the directory to the root.
WORKDIR /

# Expose the port that the application listens on.
EXPOSE 5000

# Run the application.
CMD ["python", "-m", "wikmd.wiki"]
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ It’s a file-based wiki that aims to simplicity. Instead of storing the data in

To view the documents in the browser, the document is converted to html.

![preview](static/images/readme-img.png)
![preview](src/wikmd/static/images/readme-img.png)

## Features

Expand All @@ -31,6 +31,10 @@ To view the documents in the browser, the document is converted to html.

Detailed installation instruction can be found [here](https://linbreux.github.io/wikmd/installation.html).

## Development

Instructions on the easiest way to develop on the project can be found [here](https://linbreux.github.io/wikmd/development.html).

## Plugins & Knowledge graph (beta)

More info can be found in the [docs](https://linbreux.github.io/wikmd/knowledge%20graph.html).
Expand Down
39 changes: 0 additions & 39 deletions docker/Dockerfile

This file was deleted.

38 changes: 0 additions & 38 deletions docker/Dockerfile.aarch64

This file was deleted.

38 changes: 0 additions & 38 deletions docker/Dockerfile.armhf

This file was deleted.

34 changes: 0 additions & 34 deletions docker/root/etc/cont-init.d/30-config

This file was deleted.

5 changes: 0 additions & 5 deletions docker/root/etc/services.d/wikmd/run

This file was deleted.

36 changes: 36 additions & 0 deletions docs/development.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
layout: default
title: Development
parent: Installation
nav_order: 12
---

# Regular installation
! It's tested on windows and linux based systems.
! Runs on flask server

Clone the repository
```
git clone https://github.com/Linbreux/wikmd.git
```

cd in wikmd
```
cd wikmd
```

Create a virtual env and activate it (optional, but highly recommended)
```
virtualenv venv
source venv/bin/activate
```

Install it in [development mode aka editable install](https://setuptools.pypa.io/en/latest/userguide/development_mode.html)
```
python -m pip install .[dev] --editable
```

Run the wiki
```
python -m wikmd.wiki
```
Loading

0 comments on commit b87ae28

Please sign in to comment.