A set of configuration files etc. to start developing and learning Elixir/Phoenix application using Vagrant
- Debian 10 (Buster)
- Erlang/OTP 22.2.4
- Elixir 1.9.4
- Phoenix 1.4.12
- Node.js 10.18
- npm 6.13
- PostgreSQL 12 (on Alpine)
- Oracle VM VirtualBox 6.0/6.1
- Vagrant 2.2 or above
- Git 2.7 or above
- macOS 10.15 Catalina
- macOS 10.14 Mojave
- Windows 10 Pro
- Windows 10 Home
% git config --global core.autocrlf input
% git clone https://github.com/oiax/phx-vagrant.git
% cd phx-vagrant
% vagrant plugin install vagrant-disksize
% vagrant up
% vagrant ssh
$ bin/setup.sh
Building this environment for the first time can take over two hours.
$ bin/login.sh
> mix phx.new my_app
> cd my_app
Open config/dev.exs
with a text editor and change the value of hostname
from "localhost"
to "db"
.
You can use a text editor on the host machine or on the Docker container to edit it.
> mix ecto.create
> exit
$ bin/start.sh
> cd my_app
> mix phx.server
Open http://localhost:4000
with your browser on the host machine.
You can stop the server by typing Ctrl-C
on the terminal.
$ bin/login.sh
> cd my_app
> mix phx.gen.schema Blog.Post blog_posts title:string
> exit
$ bin/stop.sh
$ exit
% vagrant halt
The projects
directory (A) on the host PC and the /projects
directory (B)
in the web
container are automatically synchronized in both directions.
Files created and updated in one directory are created and updated in the other directory almost instantly.
However, there is a delay of a few seconds before files and directories created on B are reflected on A.
Deletion of files and directories is not automatically synced, but you can sync from A to B with the following command:
$ bin/sync_to_container.sh
Think of moving and renaming files and directories as a combination of copying and deleting files and directories. This means that file and directory replicas are automatically synced from A to B, while file and directory deletions must be synced manually.
Files and directories cannot be deleted in B. Even if you try to delete it, it will be synced immediately from A.