Skip to content

Commit a42eacb

Browse files
authored
Fix stacks examples (#1125)
## Summary Cleaning up the stacks examples as some of them are out-of-date. ## How was it tested? on devbox.sh --------- Signed-off-by: Lucille Hua <[email protected]>
1 parent c087018 commit a42eacb

File tree

16 files changed

+111
-1701
lines changed

16 files changed

+111
-1701
lines changed

examples/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Devbox Examples
22

3-
[![Built with Devbox](https://jetpack.io/devbox/img/shield_moon.svg)](https://jetpack.io/devbox/docs/contributor-quickstart/)
3+
[![Built with Devbox](https://jetpack.io/img/devbox/shield_moon.svg)](https://jetpack.io/devbox/docs/contributor-quickstart/)
44

55
Example dev environments built with Devbox:
66

examples/stacks/django/README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Django Example
22

3-
[![Built with Devbox](https://jetpack.io/devbox/img/shield_moon.svg)](https://jetpack.io/devbox/docs/contributor-quickstart/)
3+
[![Built with Devbox](https://jetpack.io/img/devbox/shield_moon.svg)](https://jetpack.io/devbox/docs/contributor-quickstart/)
44

5-
[![Open In Devbox.sh](https://jetpack.io/img/devbox/open-in-devbox.svg)](https://devbox.sh/github.com/jetpack-io/devbox-examples?folder=stacks/django)
5+
[![Open In Devbox.sh](https://jetpack.io/img/devbox/open-in-devbox.svg)](https://devbox.sh/new?template=django)
66

77
## How to Use
88

@@ -17,17 +17,17 @@
1717
### Setting up the Project
1818

1919
1. Install [Devbox](https://www.jetpack.io/devbox/docs/installing_devbox/).
20-
1. Run `devbox init` to create a new Devbox project in your directory.
21-
1. Install Python and PostgreSQL with `devbox install python python310Packages.pip openssl postgresql`. This will also install the Devbox plugins for pip (which sets up your .venv directory) and PostgreSQL.
20+
1. Run `devbox create --template django` to create a new Devbox project in your directory.
21+
1. Install Python and PostgreSQL with `devbox install`. This will also install the Devbox plugins for pip (which sets up your .venv directory) and PostgreSQL.
2222
1. Copy the requirements.txt and `todo_project` directory into the root folder of your project
23-
1. Start a devbox shell with `devbox shell`, then activate your virtual environment and install your requirements using the commands below.
23+
1. Start a devbox shell with `devbox shell`. This will activate your virtual environment and install your requirements using the commands below.
2424

2525
```bash
2626
source $VENV_DIR/bin/activate
2727
pip install -r requirements.txt
2828
```
2929

30-
You can also add these lines to your `init_hook` to automatically activate your venv whenever you start your shell
30+
These lines are already added to your `init_hook` to automatically activate your venv.
3131

3232

3333
### Setting up the Database

examples/stacks/django/devbox.json

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,40 @@
11
{
2-
"packages": [
3-
"python310",
4-
"openssl@latest",
5-
"python310Packages.pip",
6-
"postgresql@latest"
2+
"packages": [
3+
"python310",
4+
"openssl@latest",
5+
"python310Packages.pip",
6+
"postgresql@latest"
7+
],
8+
"env": {
9+
"PGPORT": "5434"
10+
},
11+
"shell": {
12+
"init_hook": [
13+
". $VENV_DIR/bin/activate",
14+
"pip install -r requirements.txt"
715
],
8-
"env": {
9-
"PGPORT": "5434"
10-
},
11-
"shell": {
12-
"init_hook": [
13-
". $VENV_DIR/bin/activate",
14-
"pip install -r requirements.txt"
15-
],
16-
"scripts": {
17-
"create_db": [
18-
"echo \"Creating DB\"",
19-
"dropdb --if-exists todo_db",
20-
"createdb todo_db",
21-
"psql todo_db -c \"CREATE USER todo_user WITH PASSWORD 'secretpassword';\"",
22-
"python todo_project/manage.py makemigrations",
23-
"python todo_project/manage.py migrate"
24-
],
25-
"initdb": [
26-
"initdb"
27-
],
28-
"server": [
29-
"python todo_project/manage.py runserver"
30-
],
31-
"test": [
32-
"initdb",
33-
"devbox services start",
34-
"devbox run create_db",
35-
"python todo_project/manage.py test",
36-
"devbox services stop"
37-
]
38-
}
16+
"scripts": {
17+
"create_db": [
18+
"echo \"Creating DB\"",
19+
"dropdb --if-exists todo_db",
20+
"createdb todo_db",
21+
"psql todo_db -c \"CREATE USER todo_user WITH PASSWORD 'secretpassword';\"",
22+
"python todo_project/manage.py makemigrations",
23+
"python todo_project/manage.py migrate"
24+
],
25+
"initdb": [
26+
"initdb"
27+
],
28+
"server": [
29+
"python todo_project/manage.py runserver"
30+
],
31+
"test": [
32+
"initdb",
33+
"devbox services start",
34+
"devbox run create_db",
35+
"python todo_project/manage.py test",
36+
"devbox services stop"
37+
]
3938
}
39+
}
4040
}

examples/stacks/django/devbox.lock

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,14 @@
11
{
22
"lockfile_version": "1",
33
"packages": {
4-
"openssl": {
5-
"resolved": "github:NixOS/nixpkgs/f80ac848e3d6f0c12c52758c0f25c10c97ca3b62#openssl"
6-
},
74
"openssl@latest": {
85
"last_modified": "2023-05-01T16:53:22Z",
96
"resolved": "github:NixOS/nixpkgs/8670e496ffd093b60e74e7fa53526aa5920d09eb#openssl",
107
"version": "3.0.8"
118
},
12-
"postgresql": {
13-
"resolved": "github:NixOS/nixpkgs/f80ac848e3d6f0c12c52758c0f25c10c97ca3b62#postgresql"
14-
},
159
"postgresql@latest": {
1610
"last_modified": "2023-05-01T16:53:22Z",
11+
"plugin_version": "0.0.1",
1712
"resolved": "github:NixOS/nixpkgs/8670e496ffd093b60e74e7fa53526aa5920d09eb#postgresql",
1813
"version": "14.7"
1914
},
@@ -26,4 +21,4 @@
2621
"resolved": "github:NixOS/nixpkgs/f80ac848e3d6f0c12c52758c0f25c10c97ca3b62#python310Packages.pip"
2722
}
2823
}
29-
}
24+
}

examples/stacks/drupal/.envrc

Lines changed: 0 additions & 7 deletions
This file was deleted.

examples/stacks/drupal/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33
This example shows how to run a Drupal application in Devbox. It makes use of the PHP and Apache Plugins, while demonstrating how to configure a MariaDB instance to work with Devbox Cloud.
44

5-
[![Open In Devbox.sh](https://jetpack.io/img/devbox/open-in-devbox.svg)](https://devbox.sh/github.com/jetpack-io/devbox-examples?folder=stacks/drupal)
5+
[![Open In Devbox.sh](https://jetpack.io/img/devbox/open-in-devbox.svg)](https://devbox.sh/new?template=drupal)
66

77
## How to Run the example
88

99
In this directory, run:
1010

1111
`devbox shell`
1212

13-
To start all your services (PHP, MySQL, and NGINX), run `devbox run start_services`. To stop the services, run `devbox run stop_services`
13+
To start all your services (PHP, MySQL, and NGINX), run `devbox services up`. To stop the services, run `devbox services stop`
1414

1515
To create the `devbox_drupal` database and example table, you should run:
1616

examples/stacks/drupal/devbox.lock

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,23 @@
11
{
22
"lockfile_version": "1",
33
"packages": {
4-
"git": {
5-
"resolved": "github:NixOS/nixpkgs/f80ac848e3d6f0c12c52758c0f25c10c97ca3b62#git"
6-
},
74
"git@latest": {
85
"last_modified": "2023-05-01T16:53:22Z",
96
"resolved": "github:NixOS/nixpkgs/8670e496ffd093b60e74e7fa53526aa5920d09eb#git",
107
"version": "2.40.1"
118
},
12-
"mariadb": {
13-
"plugin_version": "0.0.1",
14-
"resolved": "github:NixOS/nixpkgs/f80ac848e3d6f0c12c52758c0f25c10c97ca3b62#mariadb"
15-
},
169
"mariadb@latest": {
1710
"last_modified": "2023-05-01T16:53:22Z",
1811
"plugin_version": "0.0.1",
1912
"resolved": "github:NixOS/nixpkgs/8670e496ffd093b60e74e7fa53526aa5920d09eb#mariadb",
2013
"version": "10.6.12"
2114
},
22-
"nginx": {
23-
"plugin_version": "0.0.1",
24-
"resolved": "github:NixOS/nixpkgs/f80ac848e3d6f0c12c52758c0f25c10c97ca3b62#nginx"
25-
},
2615
"nginx@latest": {
2716
"last_modified": "2023-05-01T16:53:22Z",
2817
"plugin_version": "0.0.1",
2918
"resolved": "github:NixOS/nixpkgs/8670e496ffd093b60e74e7fa53526aa5920d09eb#nginx",
3019
"version": "1.24.0"
3120
},
32-
"php81": {
33-
"plugin_version": "0.0.1",
34-
"resolved": "github:NixOS/nixpkgs/f80ac848e3d6f0c12c52758c0f25c10c97ca3b62#php81"
35-
},
36-
"php81Packages.composer": {
37-
"resolved": "github:NixOS/nixpkgs/f80ac848e3d6f0c12c52758c0f25c10c97ca3b62#php81Packages.composer"
38-
},
3921
"php81Packages.composer@latest": {
4022
"last_modified": "2023-05-01T16:53:22Z",
4123
"resolved": "github:NixOS/nixpkgs/8670e496ffd093b60e74e7fa53526aa5920d09eb#php81Packages.composer",

examples/stacks/jekyll/README.md

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,22 @@
11
# Jekyll Example
22

3-
[![Built with Devbox](https://jetpack.io/devbox/img/shield_moon.svg)](https://jetpack.io/devbox/docs/contributor-quickstart/)
3+
[![Built with Devbox](https://jetpack.io/img/devbox/shield_moon.svg)](https://jetpack.io/devbox/docs/contributor-quickstart/)
44

5-
[![Open In Devbox.sh](https://jetpack.io/img/devbox/open-in-devbox.svg)](https://devbox.sh/github.com/jetpack-io/devbox-examples?folder=stacks/jekyll)
5+
[![Open In Devbox.sh](https://jetpack.io/img/devbox/open-in-devbox.svg)](https://devbox.sh/new?template=jekyll)
66

77
Inspired by https://litchipi.github.io/nix/2023/01/12/build-jekyll-blog-with-nix.html
88

99
## How to Use
1010

1111
1. Install [Devbox](https://www.jetpack.io/devbox/docs/installing_devbox/)
12-
2. Run `devbox shell` to install your packages and run the init hook
13-
3. In the root directory, run `devbox run generate` to install and package the project with bundler
14-
4. In the root directory, run `devbox run serve` to start the server. You can access the Jekyll example at `localhost:4000`
15-
16-
## How to Create this Example from Scratch
17-
18-
1. Install [Devbox](https://www.jetpack.io/devbox/docs/installing_devbox/)
19-
1. In a new directory, run `devbox init` to create an empty config
20-
1. Run `devbox add ruby_3_1 bundler` to add Ruby and Bundler to your packages
21-
1. Add `"gem install jekyll --version \"~> 3.9.2\""` to your init hook. This will install the Jekyll gem in your local project.
22-
1. Start your `devbox shell`, then run `jekyll new myblog` to create the starter project.
23-
1. From here you can install the project using Bundler, and start the server using `jekyll serve`. See the scripts in this example for more details.
12+
1. Create a new project with:
13+
```bash
14+
devbox create --template jekyll
15+
devbox install
16+
```
17+
1. Run `devbox shell` to install your packages and run the init hook
18+
1. In the root directory, run `devbox run generate` to install and package the project with bundler
19+
1. In the root directory, run `devbox run serve` to start the server. You can access the Jekyll example at `localhost:4000`
2420

2521
## Related Docs
2622

examples/stacks/jekyll/process-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Process compose for starting django
1+
# Process compose for starting jekyll
22
version: "0.5"
33

44
processes:

0 commit comments

Comments
 (0)