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

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

Photo by on

Getting Started 🔫

Serving a react build is pretty straightforward and implemented the same way for many frameworks/libraries. (see more for ).
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 . 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:

│ ├───package.json
│ ├───....

│ ├───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.



DevSecOps ——

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store