Skip to content

Commit f8e5f63

Browse files
authored
Merge pull request #63 from ochan1/no_vagrant_conda
Convert to Conda with Ruby environment
2 parents a326ccd + 92abdb2 commit f8e5f63

9 files changed

+91
-256
lines changed

Makefile

-52
This file was deleted.

README.md

+32-74
Original file line numberDiff line numberDiff line change
@@ -1,104 +1,62 @@
11
# tbpweb
2-
TBP CA-A website rework, build in Django
2+
TBP CA-A website, built in Django
33

4-
## Setup
4+
## Prerequisites
55

6-
**Vagrant** will automatically setup a virtual machine with the correct
7-
setup for developing `hknweb`.
6+
For a more detailed explaination and instruction on what to install, see the [Setup's Prerequisites section](https://github.com/TBP-IT/tbpweb/wiki/Setup#prerequisites)
87

9-
Install [Vagrant](https://www.vagrantup.com/) and [VirtualBox](https://www.virtualbox.org/wiki/Downloads)
10-
It is okay to install the latest of both (and mostly recommended)! Otherwise, consult with another Officer who has the setup working and first try to match the VirtualBox version and then the Vagrant version.
8+
In summary, you need the following installed:
9+
* `git`
10+
* Any `sh` shell (e.g. `bash`, `zsh`, etc.) / `Git Bash` on Windows
11+
* Miniconda (or Anaconda)
12+
* Ruby (OCF uses 2.7.7, but we can use 3.1.X) (Windows should use `Ruby+Devkit`)
13+
* Install "Compass": `gem install compass -v 1.0.3`
1114

12-
*In one point in time, there have been some issues in the past with other versions of Virtual Box in terms of compatibility of Vagrant.
13-
You can find those here [VirtualBox Old 6.0 Builds](https://www.virtualbox.org/wiki/Download_Old_Builds_6_0), and at the time, Virtual Box 6.0.14 was recommended*
15+
## Setup and Development
1416

15-
Fork the tbpweb repository and clone your fork to your local machine
17+
For a more detailed explaination and breakdown, see the [Setup Wiki](https://github.com/TBP-IT/tbpweb/wiki/Setup)
1618

17-
Open terminal, and cd into the cloned directory (if on Windows, be sure to run Command Prompt instead, as administrator). Check to make sure there is a Vagrantfile in the directory. If on Windows, also run VirtualBox as admin. Then, from the cloned directory in terminal, type
19+
Fork the tbpweb repository and clone your fork to your local machine
1820

19-
```sh
20-
$ vagrant up
21-
```
22-
23-
which will download and boot a Linux virtual machine, then run setup.
24-
25-
To access the environment, run
26-
27-
```sh
28-
$ vagrant ssh
29-
```
30-
31-
which will `ssh` your terminal into the virtual machine.
32-
33-
See [Development](#development) for how to run the Django web server.
34-
35-
From here, run
36-
37-
```sh
38-
$ cd tbpweb
39-
```
40-
41-
Developing on `tbpweb` requires a virtual environment so that every developer has the exact same development environment i.e. any errors that a developer has is not due to difference in configuration. We will be using Python's built-on [`venv`](https://docs.python.org/3/library/venv.html) to make our virtual environment. This command creates our virtual environment.
42-
43-
```sh
44-
$ make venv
45-
```
46-
47-
Next, we need to have our current terminal/shell use the virtual environment we just created. We do this through:
48-
49-
```sh
50-
$ source .venv/bin/activate
51-
```
52-
53-
To install all dependencies (including django), run
54-
55-
```sh
56-
$ make install
57-
```
58-
There may be warnings that installation of some packages failed, but as long as you can run the command below successfully you are good to go.
21+
All commands must be ran on a `sh` shell
5922

60-
If you make any Django changes (to the database models, for instance) you will have to create and migrate migrations. You can do so with the command below. If there were changes to database models made by other developers and you pulled those changes, you just have to run make migrate.
23+
In summary, the commands you will use are (in general this order):
6124
```sh
62-
$ make migrations
63-
$ make migrate
25+
$ cd tbpweb # enter our main directory
26+
$ conda env create -f config/tbpweb-dev.yml # create our Conda Environment and install dependencies
27+
$ conda activate tbpweb-dev # enter our Conda Environment
28+
$ python manage.py makemigrations # Create migrations files
29+
$ python manage.py migrate # apply all database changes
30+
$ python manage.py runserver 0.0.0.0:3000 # start local web server
31+
$ conda deactivate # Exit the Conda Environment
6432
```
6533

66-
If you would like to access the admin interface, create a superuser using the command
67-
```sh
68-
$ make superuser
69-
```
34+
You may choose to remove the development environment by running: `conda env remove --name tbpweb-dev`
7035

71-
Finally, to run the web instance, simply run the command
36+
### Development
7237

38+
To run the Django development server (which runs a web server locally), run
7339
```sh
74-
$ make run
40+
$ python manage.py runserver 0.0.0.0:3000
7541
```
76-
This will start the development server at http://0.0.0.0:3000/. If you go into your web browser and access localhost:3000, you should be able to see the site now!
77-
78-
To access the admin site, access http://0.0.0.0:3000/admin. Use the credentials you created for your superuser to login.
79-
80-
To exit out of the pipenv shell, run
42+
which will make the web site available at `http://localhost:3000`.
8143

44+
If you would like to access the admin interface in the local web server, run
8245
```sh
83-
$ exit
46+
$ python manage.py createsuperuser
8447
```
85-
The same command can be used to exit out of the virtual machine ssh connection.
86-
87-
To turn off the virtual machine, run
8848

89-
```sh
90-
$ vagrant halt
91-
```
49+
You will be prompted for some login info, after which you should be able to access the admin interface with your super user credentials at `http://localhost:3000/admin`.
9250

93-
which will attempt to safely shutdown the virtual machine, or kill it otherwise.
51+
If there are development conflicts between Operating System, a solution that works on Linux takes precedence (as the destination OS on Berkeley's OCF)! Unix developers should also try to make their code Windows-friendly for the Window developers.
9452

9553
## Deploy
9654

9755
Make sure all changes to be pushed are in `tbpweb`'s `master` branch
9856

99-
Deploy by running `fab --prompt-for-login-password deploy` in the Vagrant VM and enter the TBP OCF credentials
57+
Deploy by running `fab --prompt-for-login-password deploy` in the Conda Environment and enter the TBP OCF password
10058

101-
This script is adapted from HKN's fabfile, so you can find other commands (including rollback) here: https://github.com/compserv/hknweb/wiki/Deployment
59+
Other fabfile commands (including rollback) here: https://github.com/TBP-IT/tbpweb/wiki/Deployment
10260

10361
## Various links to understand some of the code structure and tools
10462

Vagrantfile

-100
This file was deleted.

requirements.txt config/requirements.txt

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
pip==22.3.1
2+
setuptools==66.1.1
13
-i https://pypi.python.org/simple/
24
bcrypt==3.1.7
35
certifi==2019.9.11
@@ -17,9 +19,8 @@ fabric==2.4.0
1719
gunicorn==19.9.0
1820
idna==2.8
1921
invoke==1.3.0
20-
python-magic==0.4.24
22+
python-magic-bin==0.4.14
2123
markdown==3.1.1
22-
mysqlclient==1.3.14
2324
oauthlib==3.1.0
2425
paramiko==2.6.0
2526
pillow==6.2.0
@@ -28,7 +29,7 @@ pyjwt==1.7.1
2829
pynacl==1.3.0
2930
python3-openid==3.1.0 ; python_version >= '3.0'
3031
pytz==2019.3
31-
git+https://github.com/dresiu/recaptcha-client-1.0.6-py3
32+
git+https://github.com/TBP-IT/recaptcha-client-1.0.6-py3
3233
requests-oauthlib==1.2.0
3334
requests==2.22.0
3435
South==1.0.2

config/tbpweb-dev.yml

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: tbpweb-dev
2+
dependencies:
3+
- python=3.7
4+
- pip
5+
- pip:
6+
- -r requirements.txt
7+
- pre-commit==1.14.4
8+
- pytest==4.3.0
9+
- pytest-django==3.4.7
10+
- tox==3.7.0
11+
- livereload==2.6.0
12+
# - coverage[toml]==6.3.2
13+
# - black==22.3.0
14+
variables:
15+
TBPWEB_MODE: "dev"
16+
DJANGO_SETTINGS_MODULE: "settings"
17+
DJANGO_WSGI_MODULE: "settings.wsgi"

config/tbpweb-prod.yml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
name: tbpweb-prod
2+
dependencies:
3+
- python=3.7
4+
- pip
5+
- pip:
6+
- -r requirements.txt
7+
- mysqlclient==2.1.0
8+
variables:
9+
TBPWEB_MODE: "production"
10+
DJANGO_SETTINGS_MODULE: "settings"
11+
DJANGO_WSGI_MODULE: "settings.wsgi"

0 commit comments

Comments
 (0)