Skip to content

Commit 2bd77b0

Browse files
authored
Merge pull request #7 from wikimediabrasil/one-repo-to-rule-them-all
One repo to rule them all
2 parents 817d098 + 7f37f46 commit 2bd77b0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+8498
-1031
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Toolforge Deploy
2+
on:
3+
push:
4+
branches: [ "main" ]
5+
6+
jobs:
7+
deploy:
8+
name: Deploy to Toolforge
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- name: Configure SSH key
13+
uses: shimataro/ssh-key-action@v2
14+
with:
15+
key: ${{ secrets.SSH_PRIVATE_KEY }}
16+
known_hosts: ${{ secrets.SSH_KNOWN_HOSTS }}
17+
18+
- name: Run deployment commands
19+
uses: appleboy/ssh-action@v1.0.3
20+
with:
21+
host: ${{ vars.SSH_HOST }}
22+
username: ${{ secrets.SSH_USER }}
23+
key: ${{ secrets.SSH_PRIVATE_KEY }}
24+
port: ${{ vars.SSH_PORT }}
25+
request_pty: true
26+
script: |
27+
set -xe
28+
become infographics git -C ./www/python/src pull origin main
29+
become infographics webservice node18 shell -- npm --prefix ./www/python/client/ install
30+
become infographics webservice --mem 1Gi node18 shell -- npm --prefix ./www/python/client/ run build
31+
become infographics mkdir -p ./www/python/src/web/templates
32+
become infographics mkdir -p ./www/python/src/web/static/frontend
33+
become infographics cp ./www/python/client/dist/index.html ./www/python/src/web/templates/index.html
34+
become infographics cp -r ./www/python/client/dist/assets ./www/python/src/web/static/frontend/assets
35+
become infographics webservice python3.11 shell -- webservice-python-bootstrap
36+
become infographics webservice python3.11 shell -- ./www/python/venv/bin/python ./www/python/src/manage.py migrate
37+
become infographics webservice python3.11 shell -- ./www/python/venv/bin/python ./www/python/src/manage.py collectstatic --noinput
38+
become infographics webservice python3.11 restart
39+
become infographics webservice python3.11 status

.gitignore

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
1-
# Created by https://www.toptal.com/developers/gitignore/api/react
2-
# Edit at https://www.toptal.com/developers/gitignore?templates=react
1+
# Django collected static files
2+
/src/static
3+
4+
# Static files and templates from frontend code
5+
/src/web/static/frontend
6+
/src/web/templates/index.html
37

4-
### react ###
58
.DS_*
69
*.log
710
logs
811
**/*.backup.*
912
**/*.back.*
1013
/.idea
14+
/dist
15+
/client/dist
1116

1217
node_modules
1318
bower_components
@@ -19,4 +24,14 @@ thumb
1924
sketch
2025
.env
2126

22-
# End of https://www.toptal.com/developers/gitignore/api/react
27+
28+
.idea
29+
__pycache__
30+
*/__pycache__
31+
config.yaml
32+
Lib/
33+
Scripts/
34+
.venv/
35+
venv/
36+
*.db
37+
*.sqlite3

Dockerfile

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
FROM docker-registry.tools.wmflabs.org/toolforge-node18-sssd-web:latest AS frontend
2+
3+
COPY client /client
4+
WORKDIR /client
5+
6+
RUN npm install
7+
RUN npm run build
8+
9+
FROM docker-registry.tools.wmflabs.org/toolforge-python311-sssd-web:latest AS runner
10+
11+
WORKDIR /root/www/python/
12+
13+
COPY src/requirements.txt ./src/requirements.txt
14+
RUN webservice-python-bootstrap
15+
16+
COPY src ./src
17+
WORKDIR /root/www/python/src/
18+
19+
COPY --from=frontend /client/dist/index.html ./web/templates/index.html
20+
COPY --from=frontend /client/dist/assets ./web/static/frontend/assets
21+
22+
EXPOSE 7840
23+
CMD ["/bin/bash", "-c", "source ../venv/bin/activate && \
24+
python3 manage.py collectstatic --no-input && \
25+
python3 manage.py migrate && \
26+
python3 manage.py runserver 0.0.0.0:7840"]

README.md

Lines changed: 8 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,20 @@
11
# Wiki Infographics
22

3-
Wiki Infographics is a platform to leverage structured information within Wikimedia projects to create informative and visually engaging infographics in both fixed and dynamic formats, under an open license. It is available at https://infographics.toolforge.org.
3+
Wiki Infographics is a platform to leverage structured information within Wikimedia projects to create informative and visually engaging infographics in both fixed and dynamic formats, under an open license. It is available at <https://infographics.toolforge.org>.
44

5-
The backend codebase is available in this repository [wiki_infographics-backend](https://github.com/WikiMovimentoBrasil/wiki_infographics-backend)
5+
The tool is composed of a Django backend and a React frontend, both on this repository.
66

7-
## Table of Contents
7+
## Running locally
88

9-
- [Getting Started](#getting-started)
10-
- [Prerequisites](#prerequisites)
11-
- [Installation](#installation)
12-
- [Contributing](#contributing)
13-
- [License](#license)
9+
To run the tool locally, you need Docker and Docker Compose.
1410

15-
## Getting started:
16-
17-
### Prerequisites
18-
19-
Before you begin, ensure you have met the following requirements:
20-
21-
- Nodejs >= v18.16.0
22-
23-
### Installation
24-
25-
1. Clone the repository
26-
27-
```bash
28-
git clone https://github.com/WikiMovimentoBrasil/wiki_infographics.git
29-
30-
```
31-
32-
2. Navigate to the project directory:
33-
34-
```bash
35-
cd wiki_infographics
36-
37-
```
38-
39-
3. Install project dependencies:
40-
41-
```bash
42-
npm install
43-
44-
```
45-
46-
4. Start the development server:
47-
```bash
48-
npm run dev
49-
```
50-
51-
You should now be able to access the project at http://localhost:5173 in your web browser
52-
53-
To connect backend with this frontend go to this repository
54-
[wiki_infographics-backend](https://github.com/WikiMovimentoBrasil/wiki_infographics-backend)
55-
56-
## Running in toolforge
57-
58-
### Rebuild the image (after a code change)
59-
```
60-
> ssh login.toolforge.org
61-
> toolforge~# become <yourtool>
62-
> yourtool@toolforge~# toolforge build start <url_for_this_repo>
63-
> yourtool@toolforge~# toolforge webservice buildservice restart
11+
```bash
12+
docker-compose up --build
6413
```
6514

66-
More info on buildservice (debugging, etc.) [here](https://wikitech.wikimedia.org/wiki/Help:Toolforge/Build_Service)
67-
68-
## Contributing
69-
70-
Contributions are welcome! To contribute to Wiki Infographics, follow these steps:
15+
Open the app at <https://localhost:7840>.
7116

72-
1. Fork the repository
73-
2. Create a new branch: git checkout -b feature/your-feature
74-
3. Make your changes and commit them: git commit -m 'Add some feature'
75-
4. Push to the branch: git push origin feature/your-feature
76-
5. Create a pull request on GitHub
17+
If you make any changes, you can kill the process and run again, or restart the app container with `docker-compose up -d --build --force-recreate app`.
7718

7819
## Todos
7920

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)