When working in a start-up with a shared office, meaning there were no fixed working places, we relied on calendar entries to coordinate office utilization. However, this did not work out well due to the following reasons:
- It was not easy to see who would be in the office, which is interesting, as it ensures you meet your development team when visiting the office.
- The entries in the calendar cluttered the whole calendar, leading to the "reservations" not being updated and nobody viewing the entries anymore.
These habits led to the problem that we had days on which the office was empty and other days where more people than workplaces have been in the office. Unfortunately, it happened regularly that multiple people didn't have an actual working place, needed to work in the kitchen or did not find a suitable place to work.
This project aims to provide a simple solution to manage the capacity of a shared office.
β Full day workplace reservations (only 1 click needed)
β Recurring reservations
β Admin panel for managing reservations, offices and workplaces
β Overview of office occupancy
β EMail Verification (take care when granting access to users as admin)
Test the features with the live-demo!
As I am using the Oracle Cloud Free Tier to deploy the live demo, the live demo might eventually be unavailable.
-
Install Docker and docker-compose on the VM (e.g. linux:ubuntu)
-
Clone this Repository on your VM, and change into the directory
git clone https://github.com/florian-glombik/workplace-reservation.git
and
cd workplace-reservation
-
Fill in your custom data in
/infra/.env
(client and server need to have different domains for the reverse proxy caddy to work)vi infra/.env
-
Adjust your primary server URL in the config file
webapp/.env
vi webapp/.env
-
Create the network
web
docker network create web
-
Build and start the containers of the services needed
- Make sure the Dockerfiles match your VM architecture (ARM vs AMD, you will only need to comment/uncomment a few lines)
and
vi ~/workplace-reservation/server/Dockerfile
vi ~/workplace-reservation/webapp/Dockerfile
- Execute the docker-compose file in the folder
infra
docker-compose -f infra/docker-compose.yml up -d
- Make sure the Dockerfiles match your VM architecture (ARM vs AMD, you will only need to comment/uncomment a few lines)
-
Create the database by manually executing the following command in the
server
folder (make sure to adjust the statement according to your environment variables and docker container names) (install make if not present)sudo apt-get -y install make
cd server
and
make create_db
-
install migrate for database migrations
-
Find the release that fits your environment
-
Adjust the download command accordingly (
$version
,$os
and$arch
need to be adjusted according to the fitting release from the previous step)curl -L https://github.com/golang-migrate/migrate/releases/download/$version/migrate.$os-$arch.tar.gz
e.g. this could look like this for an amd ubuntu VM:
curl -L -o migrate.linux-amd64.tar.gz https://github.com/golang-migrate/migrate/releases/download/v4.15.2/migrate.linux-amd64.tar.gz
-
Extract the downloaded archive
tar xvzf migrate.$os-$arch.tar.gz
e.g. this could look like this for an amd ubuntu VM:
tar xvzf migrate.linux-amd64.tar.gz
-
Make the command usable by moving it to the
bin
foldersudo mv migrate /usr/local/bin/
-
You have installed migrate π
Execute the following to double-check the installation was successfull
migrate -version
-
-
Execute the database migration in the folder
server
(make sure to adjust the migrate_up command according to your environment variables and docker container names)make migrate_up
-
The service should be up and running, checkout your domain!
-
Create a user by navigating to your client URL and registering as user
-
Give your user Admin rights manually
- Open a shell on the
database
container, e.g. withdocker exec -it database bash
- Start psql by executing
psql
- Connect to the database (list databases with ``\l`)
\connect workplace_reservation
- Update the
role
of your user with SQL toadmin
- List the available tables
\dt
- View the entry of your user in the database
SELECT * FROM users;
- Update the role of your user
UPDATE users SET role = 'admin', access_granted = true WHERE id = '<your-user-id>';
- Check if the role has been updated properly
SELECT * FROM users;
- Exit the psql shell
\q
- List the available tables
- Open a shell on the
-
Logout and Login again to make sure that the admin rights are taking effect
Your instance is running and ready to be used by your and your colleagues! π
(You might want to create the offices and workplaces in the application before you share the link with your colleagues π)
Within this step I describe the process of creating a PostgreSQL when using docker.
Pull your favourite PostgreSQL docker image. I decided to use the tag 14-alpine
,
resulting in the CLI-command
docker pull postgres:14-alpine
After pulling the image, the container needs to be started:
Make sure to exchange <user-name>
and <password>
with your custom values before executing the command.
docker run --name postgres14 -p 5432:5432 -e POSTGRES_USER=<user-name> -e POSTGRES_PASSWORD=<password> -d postgres:14-alpine
We have now set up our Postgres instance within the docker container, but still need to create the database.
To do so, navigate to the folder server
. Within this folder execute the following commands:
If you did not name your container postgres14
the predefined create_db
/dop_db
commands will not work.
Make sure to adjust the commands in server/Makefile
properly to match the name of your Postgres docker container.
Create the database within the container:
make create_db
Add the database schema by running a migration:
make migrate_up
We are using sqlc to generate code for the SQL queries. We need to generate the code before running the application.
Execute the following command within the server
folder:
make sqlc
Make sure to install:
- Go - at least version 1.18
- docker - keeps our PostgresSQL database
- npm - used as package manager, e.g. for importing React
- migrate - framework used for database migrations
- sqlc - used for generation of Go code from SQL queries; there is currently (1.13) no support for Postgres sqlc for Windows
You will need to download the used packages and frameworks.
For the Go Server: Make sure to sync the imports/modules
For the Client/Webapp: Make sure to execute npm install
within the folder workplace-reservation/webapp
Make sure to use prettier
The project is based on Go and React. I use [GoLand](https://www.jetbrains.com/de-de/go/) as IDE and included my project configurations within this repository, which might save you some time getting started with the project in case you do not prefer another IDE.
If you are using GoLand the prettier configuration will look like this:
You will need to install the prettier plugin and restart the GoLand before this selection appears.
https://github.com/swaggo/gin-swagger
execute swag init
in server/src
Once you have started the server you can find a visual representation of the Swagger API.