Containerizing Go + React & Automating w/ GitHub Actions | Part 1

Part 1: Containerizing Go + React
Part 2: Automating w/ GitHub Actions + Pushing to Docker Hub

hüseyin nurbaki
2 min readJan 15, 2022
Photo by AARN GIRI on Unsplash

Getting Started 🔫

Serving a react build is pretty straightforward and implemented the same way for many frameworks/libraries. (see more for Go Fiber).
It is about serving the build output of React application.

The best practice is always packing applications separately. Lifecycles, scalability requirements, etc. are unique and specific to the application. But for some cases, a backend application can serve React build alongside its other responsibilities.

In my opinion, there is no harm in serving a small and limited UI application by a backend application. You don’t always need the flexibility like Nginx’ provides. The actual requirements of your apps/platform should be the margins while designing the solution, not the capabilities of the hottest solutions. Please comment below if you agree or disagree.

Containerization 📦

The following Dockerfile belongs to Mocktail. Depending on your application your build command can change. Mocktail is currently supporting a single database, SQLite which requires interoperation with C libs, therefore CGO is enabled.

If you look at the instruction before exposing the port, a build folder is copied. This means whenever the docker build command is executed, React App’s build folder is expected alongside the Dockerfile.

The folder structure of the demo application is:

├───mocktail-dashboard
│ ├───package.json
│ ├───....

├───mocktail-api
│ ├───Dockerfile
│ ├───...

According to the folder structure, React application is built under mocktail-dashboard, and we need it under mocktail-api before containerization.
Part 2 is about automating that procedure by using Github Actions & pushing the image to Docker Hub.

Follow for part 2. Subscribe to get an email once it’s published.

--

--