Skip to content

Commit

Permalink
Update README, scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
NdagiStanley committed Apr 29, 2020
1 parent 36ef80d commit 038f721
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 41 deletions.
11 changes: 5 additions & 6 deletions README.md
Expand Up @@ -45,13 +45,11 @@ $ npm install -g vue-cli
### Set up
You might want to use ```sudo``` if you encounter permissions error
```bash
$ vue init NdagiStanley/vue-django my-project
$ vue init NdagiStanley/vue-django my-project # Follow the prompts
$ cd my-project
$ npm install
```

Secondly, have *Python* installed and preferably create a virtual environment for the project.

### Develop
Run:
```bash
Expand All @@ -62,12 +60,13 @@ The app runs on [localhost:8080](http://localhost:8080/)

Update the files as you wish and the hot-reload will take effect. Add `js` and `css` files within the `static` folder in the root directory. Link them to the index.html in that same level (the root directory).

### Deploy
Ensure you have run `npm install` prior to the following command.
### Run the Django server
Have *Python* installed and preferably use a [virtual python environment](#virtualenv) for this.

Run:
```bash
$ .deploy.sh
$ python -m pip install -r requirements.txt
$ sh server.sh
```
(Run this command every time you make changes)

Expand Down
6 changes: 3 additions & 3 deletions docs/README.md
Expand Up @@ -100,9 +100,9 @@ $ python manage.py migrate
$ python manage.py runserver 0.0.0.0:8000
```

The 6 commands above are contained in the `deploy.sh` so running the script is as good as running the aforementioned commands:
The 6 commands above are contained in the `server.sh` so running the script is as good as running the aforementioned commands:
```
$ ./deploy.sh
$ ./server.sh
```

Open the app at [localhost:8000](localhost:8000)
Expand All @@ -117,4 +117,4 @@ If you use docker in your workflow, there is a Dockerfile (that you can build an
$ docker-compose up
```

Open the app at [localhost:8000](localhost:8000). You'll have to stop the Django server if you ran it earlier or change the port within the `deploy.sh` from `8000` to something else.
Open the app at [localhost:8000](localhost:8000). You'll have to stop the Django server if you ran it earlier or change the port within the `server.sh` from `8000` to something else.
2 changes: 1 addition & 1 deletion meta.js
Expand Up @@ -125,5 +125,5 @@ module.exports = {
"test/e2e/**/*": "e2e",
"src/router/**/*": "router"
},
"completeMessage": "To get started:\n\n {{^inPlace}}cd {{destDirName}}\n {{/inPlace}}npm install\n\n To develop:\n\n npm run dev\n\nTo build and serve in Django:\n\n ./deploy.sh (Remember to do this in a python virtual environment)\n\nDocumentation can be found at https://goo.gl/V4eN7h"
"completeMessage": "To get started:\n\n {{^inPlace}}cd {{destDirName}}\n {{/inPlace}}npm install\n\n To develop:\n\n npm run dev\n\nTo build and serve in Django:\n\n ./server.sh (Remember to do this in a python virtual environment)\n\nDocumentation can be found at https://goo.gl/V4eN7h"
};
9 changes: 4 additions & 5 deletions template/Dockerfile
Expand Up @@ -14,18 +14,17 @@ RUN curl https://bootstrap.pypa.io/get-pip.py | python3 \
&& pip3 install --upgrade pip \
&& pip3 install -r requirements.txt

# Run the following commands for deployment
# Install node modules
COPY package.json package.json
RUN npm set progress=false && npm install -s --no-progress
COPY . .
RUN npm run build
RUN python3 format_index_html.py
RUN python3 manage.py collectstatic --noinput
RUN sh build.sh

ENV DEBUG=False

# EXPOSE port to be used
ENV PORT=8000
EXPOSE 8000

# Set command to run as soon as container is up
CMD python3 manage.py runserver 0.0.0.0:8000
CMD python3 manage.py runserver 0.0.0.0:$PORT
3 changes: 2 additions & 1 deletion template/Procfile
@@ -1 +1,2 @@
web: python3 format_index_html.py && pip install -r requirements.txt && python3 manage.py collectstatic --noinput && python3 manage.py migrate && gunicorn vuedj.wsgi
release: sh build.sh
web: sh build.sh && gunicorn vuedj.wsgi
4 changes: 2 additions & 2 deletions template/README.md
Expand Up @@ -32,8 +32,8 @@ npm run e2e
npm test
{{/if_or}}

# deploy
.deploy.sh
# run server
.server.sh
```

For a detailed explanation on how things work, check out the [guide](http://vuejs-templates.github.io/webpack/) and [docs for vue-loader](http://vuejs.github.io/vue-loader).
15 changes: 15 additions & 0 deletions template/build.sh
@@ -0,0 +1,15 @@
echo '...Run npm build'
npm run build
echo '...Done...'

echo '...Format index.html as Jinja template'
python3 format_index_html.py
echo '...Done...'

echo '...Collect static'
python3 manage.py collectstatic --noinput
echo '...Done...'

echo '...Run migrations'
python3 manage.py migrate
echo '...Done...'
23 changes: 0 additions & 23 deletions template/deploy.sh

This file was deleted.

5 changes: 5 additions & 0 deletions template/server.sh
@@ -0,0 +1,5 @@
sh ./build.sh

export PORT=8000
echo '...Server runnning on port ' $PORT
python3 manage.py runserver $PORT

0 comments on commit 038f721

Please sign in to comment.