-
Notifications
You must be signed in to change notification settings - Fork 12
Running Hackerspace with Docker
The easiest way to get started is to install Docker. Docker uses a concept called containers, which allows you to get started on software without having to manually setup your development environment and install a bunch of things - Docker will handle that for you.
Installing Docker on Windows is a bit tricky so we have additional inforamation:
If running Windows 10 Pro, Enterprise, or Education, use these instructions - https://docs.docker.com/docker-for-windows/install/
If running Windows 10 Home, use these instructions - https://docs.docker.com/docker-for-windows/install-windows-home/
Issues that you may encounter:
-
Unable to install WSL 2 due to running an older version of Windows
- Solution is to install WSL 1 and then install an older version of Docker. Try installing 2.1.0.5
-
Unable to install Docker with Error: Installation Failed: one prerequisite is not fulfilled. Docker Desktop requires Windows 10 Pro or Enterprise version xxxxx to run.
- Solution is to follow this workaround to 'trick' Docker during installation
-
You can install Docker but when you build locally, your container gives the following error in the logs "standard_init_linux.go:207: exec user process caused “no such file or directory” on windows"
- Solution is to run this command "dos2unix docker-entrypoint.sh" which will convert the file to UNIX format. (source - https://stackoverflow.com/a/56880170)
Once installed and running, use Powershell to follow the instructions in the Docker Deployment Instructions section.
$ rails server
Initialise environment variables required by docker-compose
:
cp .env.example .env
IMPORTANT: Then edit .env
with a text editor and choose a more secure password for the POSTGRES_PASSWORD
variable.
If you don't want to wait for the Docker image to build from your local copy of the repo, start with:
docker pull govhackau/hackerspace3
(If you don't do the above, the image will get automatically built; this should take about 10 minutes on a modern machine.)
Run Hackerspace:
NOTE: The initial run of Hackerspace will likely take several minutes to initialise the database before being usable. This is normal.
$ docker-compose up -d
Then browse to http://localhost:3000 and click Sign In.
- Username:
admin@hackerspace.com
- Password:
password
(Note, refer to db/seeders/seeder.rb
and db/seeders/user_seeder.rb
to see where these are set)
To stop Hackerspace:
$ docker-compose down
Or, to stop and remove the Hackerspace database:
NOTE: If you do this, you'll need to re-run the "Initialise the postgres database" instructions above, the next time you want to use Hackerspace. Only do this if you want to start with a fresh database, or completely remove the Hackerspace project from Docker.
$ docker-compose down -v
To explicitly rebuild a new hackerspace3
Docker image from your local code:
docker build -t govhackau/hackerspace3 .
Or, to build the image and start the container as usual, run:
docker-compose up --build
To actively make local changes to your codebase without needing to rebuild the image, start the database image with:
docker-compose up -d postgres
Then start the govhackau/hackerspace3
image with:
docker-compose run --rm -d -v "$(pwd)":/usr/src/app --service-ports hackerspace3
NOTE: Due to the "$(pwd)" in the above command, it should work in any POSIX shell (bash/sh/zsh etc), and PowerShell. It won't work in Windows Command Prompt.
This runs the container and bind-mounts your checked out code into the container so you can work on it without needing to rebuild the container's image.