Skip to content

Fix stacks examples #1125

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jun 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Devbox Examples

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

Example dev environments built with Devbox:

Expand Down
12 changes: 6 additions & 6 deletions examples/stacks/django/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Django Example

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

[![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)
[![Open In Devbox.sh](https://jetpack.io/img/devbox/open-in-devbox.svg)](https://devbox.sh/new?template=django)

## How to Use

Expand All @@ -17,17 +17,17 @@
### Setting up the Project

1. Install [Devbox](https://www.jetpack.io/devbox/docs/installing_devbox/).
1. Run `devbox init` to create a new Devbox project in your directory.
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.
1. Run `devbox create --template django` to create a new Devbox project in your directory.
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.
1. Copy the requirements.txt and `todo_project` directory into the root folder of your project
1. Start a devbox shell with `devbox shell`, then activate your virtual environment and install your requirements using the commands below.
1. Start a devbox shell with `devbox shell`. This will activate your virtual environment and install your requirements using the commands below.

```bash
source $VENV_DIR/bin/activate
pip install -r requirements.txt
```

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


### Setting up the Database
Expand Down
72 changes: 36 additions & 36 deletions examples/stacks/django/devbox.json
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@
{
"packages": [
"python310",
"openssl@latest",
"python310Packages.pip",
"postgresql@latest"
"packages": [
"python310",
"openssl@latest",
"python310Packages.pip",
"postgresql@latest"
],
"env": {
"PGPORT": "5434"
},
"shell": {
"init_hook": [
". $VENV_DIR/bin/activate",
"pip install -r requirements.txt"
],
"env": {
"PGPORT": "5434"
},
"shell": {
"init_hook": [
". $VENV_DIR/bin/activate",
"pip install -r requirements.txt"
],
"scripts": {
"create_db": [
"echo \"Creating DB\"",
"dropdb --if-exists todo_db",
"createdb todo_db",
"psql todo_db -c \"CREATE USER todo_user WITH PASSWORD 'secretpassword';\"",
"python todo_project/manage.py makemigrations",
"python todo_project/manage.py migrate"
],
"initdb": [
"initdb"
],
"server": [
"python todo_project/manage.py runserver"
],
"test": [
"initdb",
"devbox services start",
"devbox run create_db",
"python todo_project/manage.py test",
"devbox services stop"
]
}
"scripts": {
"create_db": [
"echo \"Creating DB\"",
"dropdb --if-exists todo_db",
"createdb todo_db",
"psql todo_db -c \"CREATE USER todo_user WITH PASSWORD 'secretpassword';\"",
"python todo_project/manage.py makemigrations",
"python todo_project/manage.py migrate"
],
"initdb": [
"initdb"
],
"server": [
"python todo_project/manage.py runserver"
],
"test": [
"initdb",
"devbox services start",
"devbox run create_db",
"python todo_project/manage.py test",
"devbox services stop"
]
}
}
}
9 changes: 2 additions & 7 deletions examples/stacks/django/devbox.lock
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
{
"lockfile_version": "1",
"packages": {
"openssl": {
"resolved": "github:NixOS/nixpkgs/f80ac848e3d6f0c12c52758c0f25c10c97ca3b62#openssl"
},
"openssl@latest": {
"last_modified": "2023-05-01T16:53:22Z",
"resolved": "github:NixOS/nixpkgs/8670e496ffd093b60e74e7fa53526aa5920d09eb#openssl",
"version": "3.0.8"
},
"postgresql": {
"resolved": "github:NixOS/nixpkgs/f80ac848e3d6f0c12c52758c0f25c10c97ca3b62#postgresql"
},
"postgresql@latest": {
"last_modified": "2023-05-01T16:53:22Z",
"plugin_version": "0.0.1",
"resolved": "github:NixOS/nixpkgs/8670e496ffd093b60e74e7fa53526aa5920d09eb#postgresql",
"version": "14.7"
},
Expand All @@ -26,4 +21,4 @@
"resolved": "github:NixOS/nixpkgs/f80ac848e3d6f0c12c52758c0f25c10c97ca3b62#python310Packages.pip"
}
}
}
}
7 changes: 0 additions & 7 deletions examples/stacks/drupal/.envrc

This file was deleted.

4 changes: 2 additions & 2 deletions examples/stacks/drupal/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

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.

[![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)
[![Open In Devbox.sh](https://jetpack.io/img/devbox/open-in-devbox.svg)](https://devbox.sh/new?template=drupal)

## How to Run the example

In this directory, run:

`devbox shell`

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

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

Expand Down
18 changes: 0 additions & 18 deletions examples/stacks/drupal/devbox.lock
Original file line number Diff line number Diff line change
@@ -1,41 +1,23 @@
{
"lockfile_version": "1",
"packages": {
"git": {
"resolved": "github:NixOS/nixpkgs/f80ac848e3d6f0c12c52758c0f25c10c97ca3b62#git"
},
"git@latest": {
"last_modified": "2023-05-01T16:53:22Z",
"resolved": "github:NixOS/nixpkgs/8670e496ffd093b60e74e7fa53526aa5920d09eb#git",
"version": "2.40.1"
},
"mariadb": {
"plugin_version": "0.0.1",
"resolved": "github:NixOS/nixpkgs/f80ac848e3d6f0c12c52758c0f25c10c97ca3b62#mariadb"
},
"mariadb@latest": {
"last_modified": "2023-05-01T16:53:22Z",
"plugin_version": "0.0.1",
"resolved": "github:NixOS/nixpkgs/8670e496ffd093b60e74e7fa53526aa5920d09eb#mariadb",
"version": "10.6.12"
},
"nginx": {
"plugin_version": "0.0.1",
"resolved": "github:NixOS/nixpkgs/f80ac848e3d6f0c12c52758c0f25c10c97ca3b62#nginx"
},
"nginx@latest": {
"last_modified": "2023-05-01T16:53:22Z",
"plugin_version": "0.0.1",
"resolved": "github:NixOS/nixpkgs/8670e496ffd093b60e74e7fa53526aa5920d09eb#nginx",
"version": "1.24.0"
},
"php81": {
"plugin_version": "0.0.1",
"resolved": "github:NixOS/nixpkgs/f80ac848e3d6f0c12c52758c0f25c10c97ca3b62#php81"
},
"php81Packages.composer": {
"resolved": "github:NixOS/nixpkgs/f80ac848e3d6f0c12c52758c0f25c10c97ca3b62#php81Packages.composer"
},
"php81Packages.composer@latest": {
"last_modified": "2023-05-01T16:53:22Z",
"resolved": "github:NixOS/nixpkgs/8670e496ffd093b60e74e7fa53526aa5920d09eb#php81Packages.composer",
Expand Down
24 changes: 10 additions & 14 deletions examples/stacks/jekyll/README.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,22 @@
# Jekyll Example

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

[![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)
[![Open In Devbox.sh](https://jetpack.io/img/devbox/open-in-devbox.svg)](https://devbox.sh/new?template=jekyll)

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

## How to Use

1. Install [Devbox](https://www.jetpack.io/devbox/docs/installing_devbox/)
2. Run `devbox shell` to install your packages and run the init hook
3. In the root directory, run `devbox run generate` to install and package the project with bundler
4. In the root directory, run `devbox run serve` to start the server. You can access the Jekyll example at `localhost:4000`

## How to Create this Example from Scratch

1. Install [Devbox](https://www.jetpack.io/devbox/docs/installing_devbox/)
1. In a new directory, run `devbox init` to create an empty config
1. Run `devbox add ruby_3_1 bundler` to add Ruby and Bundler to your packages
1. Add `"gem install jekyll --version \"~> 3.9.2\""` to your init hook. This will install the Jekyll gem in your local project.
1. Start your `devbox shell`, then run `jekyll new myblog` to create the starter project.
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.
1. Create a new project with:
```bash
devbox create --template jekyll
devbox install
```
1. Run `devbox shell` to install your packages and run the init hook
1. In the root directory, run `devbox run generate` to install and package the project with bundler
1. In the root directory, run `devbox run serve` to start the server. You can access the Jekyll example at `localhost:4000`

## Related Docs

Expand Down
2 changes: 1 addition & 1 deletion examples/stacks/jekyll/process-compose.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Process compose for starting django
# Process compose for starting jekyll
version: "0.5"

processes:
Expand Down
Loading