Practical Microservices: Missing .env in chapter 1

Chapter 1 requires a .env file to run, but I didn’t see it mentioned in the chapter.

Hi TheSwitch,

The code for the first chapter does include a .env file. Did something break for you because of that file?

I likely didn’t call it out because I wasn’t trying to not get too deep into details at that point, preferring to just do the minimum to show the design problem that an MVC approach was going to give us.

Hi

Yes, the file is there in the sample code. But I always want to write the code myself. Right near the beginning of the book, that’s a practice recommended in the text. Yet it’s not possible if I have to switch to the sample code to get a running application. In particular, if I don’t know which parts of the sample code are required to get to the point of having a running application, it defeats the purpose of writing the code myself

As it turns out, the sample code doesn’t run entirely successfully, either. Even running it as-is, i.e. using the specified versions of packages and the included yaml to start up a PostgreSQL instance, the application hits errors because it times out while trying to connect to the database. I eventually managed to get around the DB problem by downloading a PostgreSQL image and finding a command line that got it running correctly. I had to add the password to the .env file as well to get around the “password cannot be an empty string” error, but I suspect that’s because, in the image downloaded by running the yaml file, the password is stored inside the image.