diff --git a/.gitignore b/.gitignore index 33c51e903..478a8af3e 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,4 @@ node_modules tags **/commands/processmon support/processmon/processmon +.vagrant diff --git a/README.md b/README.md index 69580d205..e7e3edf43 100644 --- a/README.md +++ b/README.md @@ -641,3 +641,40 @@ To bundle the latest version: ``` rake global:install_processmon ``` + +## FreeBSD setup + +There's a Vagrantfile with a FreeBSD VM included. +It requires a couple of steps to get running: + +``` +brew install --cask utm +vagrant plugin install vagrant_utm +vagrant destroy freebsd +vagrant up freebsd --provider=utm +``` + +Then in UTM, log in with `vagrant`, password `vagrant`, and run these commands. + +``` +cd /app +./run_in_vm.sh +``` + +Then, visit http://localhost:4001 + +### Syncing volumes + +The FreeBSD VM uses rsync for syncing volumes. After making changes to files on your host machine, sync them to the VM: + +``` +vagrant rsync freebsd +``` + +To automatically sync changes as you make them: + +``` +vagrant rsync-auto freebsd +``` + +This will watch for file changes and sync them automatically to the VM. diff --git a/Vagrantfile b/Vagrantfile new file mode 100644 index 000000000..b7ca2ee72 --- /dev/null +++ b/Vagrantfile @@ -0,0 +1,46 @@ + +Vagrant.configure("2") do |config| + config.vm.define "freebsd" do |freebsd| + freebsd.vm.box = "bento/freebsd-14" + freebsd.vm.box_architecture = "amd64" + freebsd.vm.guest = :freebsd + freebsd.vm.network "private_network", type: "dhcp" + freebsd.vm.synced_folder "./elixir/phoenix/app", "/app", type: "rsync", + rsync__exclude: [".git/", "node_modules/", "_build/", "deps/"] + freebsd.vm.synced_folder "./elixir/integration", "/integration", type: "rsync", + rsync__exclude: [".git/", "_build/", "deps/"] + + freebsd.vm.provider "virtualbox" do |vb| + vb.check_guest_additions = false + end + + freebsd.vm.provider "utm" do |u| + u.name = "freebsd" + u.cpus = 2 + u.memory = 2048 + u.icon = "freebsd" + u.check_guest_additions = false + end + freebsd.ssh.shell = "sh" + + freebsd.vm.hostname = "freebsd" + freebsd.vm.network "private_network", ip: "192.168.56.12" + freebsd.vm.network "forwarded_port", guest: 4001, host: 4001 + freebsd.vm.provision "shell", inline: <<-SHELL + echo test >> ~/testado + sed -e 's/\#DEFAULT_ALWAYS_YES = false/DEFAULT_ALWAYS_YES = true/g' -e 's/\#ASSUME_ALWAYS_YES = false/ASSUME_ALWAYS_YES = true/g' /usr/local/etc/pkg.conf > /tmp/pkg.conf + mv -f /tmp/pkg.conf /usr/local/etc/pkg.conf + pkg install gcc gmake openssl automake libtool wget python3 gmake lftp vim ruby-build elixir postgresql16-server postgresql16-client git + echo 'eval "$(rbenv init -)"' > ~/.bashrc + + # Set up PostgreSQL + sysrc postgresql_enable="YES" + service postgresql initdb + service postgresql start + + # Create database user and database + su -m postgres -c "createuser -s vagrant" || true + su -m vagrant -c "createdb phoenix_dev" || true + SHELL + end +end diff --git a/elixir/phoenix/app/appsignal.env b/elixir/phoenix/app/appsignal.env new file mode 100644 index 000000000..4ea8689e0 --- /dev/null +++ b/elixir/phoenix/app/appsignal.env @@ -0,0 +1,5 @@ +APPSIGNAL_WORKING_DIRECTORY_PATH=/tmp/working_directory +APPSIGNAL_LOG_PATH=/tmp +APPSIGNAL_HOSTNAME=test-setup-container +APPSIGNAL_LOG_LEVEL=trace +APPSIGNAL_IGNORE_NAMESPACES=user diff --git a/elixir/phoenix/app/config/dev.exs b/elixir/phoenix/app/config/dev.exs index 6de3aa378..81c234e9f 100644 --- a/elixir/phoenix/app/config/dev.exs +++ b/elixir/phoenix/app/config/dev.exs @@ -28,8 +28,7 @@ config :example, ExampleWeb.Endpoint, secret_key_base: "WwOZdtFSngz7DrtXHkco0fXMI0Nz73db7QJWaTEBaILtqszOeUJpYeORa2J1IAaV", watchers: [ esbuild: - {Esbuild, :install_and_run, [:example, ~w(--sourcemap=inline --watch)]}, - tailwind: {Tailwind, :install_and_run, [:example, ~w(--watch)]} + {Esbuild, :install_and_run, [:example, ~w(--sourcemap=inline --watch)]} ] # ## SSL Support diff --git a/elixir/phoenix/app/run_in_vm.sh b/elixir/phoenix/app/run_in_vm.sh new file mode 100755 index 000000000..0e1517d1e --- /dev/null +++ b/elixir/phoenix/app/run_in_vm.sh @@ -0,0 +1,28 @@ +#!/bin/sh + +set -eu + +export DATABASE_URL="ecto://postgres@localhost/phoenix_dev" +export PORT=4001 +export APPSIGNAL_APP_NAME=elixir-phoenix +export APPSIGNAL_LOG_LEVEL=trace + +# Load environment variables from env files +if [ -f /app/appsignal.env ]; then + set -a + . /app/appsignal.env + set +a +fi + +if [ -f /app/appsignal_key.env ]; then + set -a + . /app/appsignal_key.env + set +a +fi + +cd /app +mix local.hex --force +mix local.rebar --force +mix deps.get +mix ecto.migrate +mix phx.server