https://i.ytimg.com/vi/ESGYWyDaUx0/hqdefault.jpgThis is the intro of the eCommerce website that we will be building together.Laravel News Links
Using Docker to Containerize Laravel Apps for Development and Production
https://www.honeybadger.io/images/pull_image.png
In the past 5 years, both Docker and Laravel have exploded in popularity. In this step-by-step tutorial, we will dive into how to dockerize an existing Laravel app to run it on local and then make it ready to run on a production environment. We will also deploy it to Google Cloud Run without getting into Kubernetes or any YAML configs. Let’s get started
What are containers?
Containers simply put, are a way of packaging an application in a way that in addition to the application code and its dependencies the whole stack including the language, file system, and operating system can be shipped together. Another added bonus of this form of packaging is the specific version of the language and operating system can be specified in each build.
There are multiple ways to define what containers and containerization are and how they operate. But without going to the details of virtualization and hypervisors the above way to understand them is simpler.
Photo by Ian Taylor on Unsplash
If you want to refer to the shipping containers analogy, be my guest. The benefits of using containers include small size, speed, efficiency, and portability.
To oversimplify things, you can think of containers as an improved virtual machine that is smaller, faster, and more resource-efficient.
What is docker?
So if containers enable us to ship the whole stack on each deployment after a successful build of course, where does this Docker thing come into play? Docker is an open-source platform (and a company Docker Inc) that enables software engineers to package applications into containers.
Therefore, Docker is a software that lets us build, package and run our applications as containers. But it is not the only option.
Think of Docker as the AWS of the container world in terms of popularity, there is another container platform called rocket (rkt) which can be considered something like Vultr in this analogy.
The open container initiative looks at the standardization and governance of container runtimes.
Next up we will park these terms and theory here and jump into running some commands in the command line to meet our goal of creating development and production-ready containers for an existing Laravel application.
Prerequisites
Before we dive into the code and docker commands, it would be great to make sure of the following things:
- You have docker and docker-compose running on your machine
- A general familiarity with how Laravel works will be needed
- You are aware of how containers work and the need to build them and push them to a container registry.
- To deploy the application you will need a Google cloud account.
Time to go deeper into dockerizing the Laravel app.
Example application
For this post as we want to dockerize an existing Laravel application, we will use the Student CRUD app built with Laravel by Digamber Rawat. The application is open source and he has a great tutorial explaining how the app was built.
It is a relatively simple Laravel 8 application using MySQL as the database. We will fork this application and dockerize it to run it on production not only on the dev environment. I would like to thank him for his amazing work on this application.
Dockerize for local dev environment with Laravel sail
First, we will use Laravel Sail to run the application locally on our dev environment. There are unofficial Docker environments for Laravel like Laradock but Sail is the official docker dev environment for Laravel. Sail is is a wrapper on top of docker compose.
To Sail-ize
our existing student CRUD app, we will run the following command after cloning the repository:
cd laravel-crud-app
cp .env.example .env
composer require laravel/sail --dev && php artisan sail:install
After the command ran, we should select 0 for MySQL to install MySQL as part of the docker-compose file created by Laravel sail as seen below:
At this point, make sure we have the docker-compose.yml
file created at the root of the project. If the file is created, we can run the following command to build and run the needed containers:
COMPOSE_DOCKER_CLI_BUILD=1 DOCKER_BUILDKIT=1 ./vendor/bin/sail build
As Laravel Sail is a wrapper on top of Docker compose, what I have done here is instructed docker-compose to build the needed containers with BuildKit.
Docker BuildKit is build enhancement available in the newer versions of Docker that makes the docker build faster and efficient. We will see the following output when the build process is done:
Even with Docker BuildKit enabled the build process will take 5-10 minutes depending on the internet speed. To run the containers we will run the following command:
We will see an output towards the end of the command as follows:
We will have to add the APP key in the .env running the following command after the container are running:
./vendor/bin/sail artisan key:generate
We will also need to change the database credentials in the .env
file like below to make the app work.
DB_CONNECTION=mysql
DB_HOST=mysql
DB_PORT=3306
DB_DATABASE=laravel
DB_USERNAME=root
DB_PASSWORD=
By default, the MySQL container has a root user with no password, the above configuration will work. After that to create the database structure we will need to run the migrations with:
./vendor/bin/sail artisan migrate --force
Next, when we hit http://localhost/students
we should see the empty list, we can go in and add a student to have an output that looks similar to below:
Congrats! Our app is running locally with Laravel sail. Time to check production readiness for the Laravel sail container.
Is Laravel sail’s docker image ready for production
A quick check on the image size with docker images | grep sail
reveals that the docker image is 732 MB.
It is not only the size on a deeper inspection of the Docker file at ./vendor/laravel/sail/runtimes/8.0/Dockerfile
it reveals that the supervisor file is using:
command=/usr/bin/php -d variables_order=EGPCS /var/www/html/artisan serve --host=0.0.0.0 --port=80 user=sail
That does not look like a production-ready web server, it is good for local development but running PHP as a production web server is not a good idea.
The images is built on top of an Ubuntu image not the official PHP docker image. It also has Node.js 15 (not a LTS version of Node.js), yarn and composer that will not be needed for a lean production image. It has been built with the development usecase in mind.
Therefore we will create a new Dockerfile and a new docker-compose file to test out a production-ready Docker image for Laravel. As the next step we will rename the current docker-compose.yml
to docker-compose-dev-sail.yml
with:
mv docker-compose.yml docker-compose-dev-sail.yml
Similarly, the sail up command will change to:
./vendor/bin/sail -f docker-compose-dev-sail.yml up
And if we hit the URL http://localhost/students
again it should work as it was working earlier. All the changes done till now are in this pull request for your reference. Next up we will create a production-ready docker file and a docker-compose file to make it easy to test.
Dockerize the application to be production-ready
To dockerize our Student CRUD app built on Laravel we will work on the following assumptions:
- For a production environment we will be using a database as a service something like AWS RDS or Google Cloud SQL. For this demo, I will use a free remote MySQL database.
- We will only use official docker images to avoid any compatibility issues or security risks.
- The official PHP Apache image will be used to keep the complexity low and avoid having multiple containers.
- We will be using PHP 8.0 with opcache and Just In Time JIT for speed.
- Docker multi-stage build and BuildKit will be used to make images smaller and build faster.
- The database credentials are “open” for this demo in
.env.prod
file, it would be best to use environment variables to fill them up on runtime.
As the assumption are clear, we can jump to adding the docker file.
Production friendly Dockerfile for Laravel app
We can start by adding a Dockerfile like below on the root of the project:
FROM composer:2.0 as build
COPY . /app/
RUN composer install --prefer-dist --no-dev --optimize-autoloader --no-interaction
FROM php:8.0-apache-buster as production
ENV APP_ENV=production
ENV APP_DEBUG=false
RUN docker-php-ext-configure opcache --enable-opcache && \
docker-php-ext-install pdo pdo_mysql
COPY docker/php/conf.d/opcache.ini /usr/local/etc/php/conf.d/opcache.ini
COPY --from=build /app /var/www/html
COPY docker/000-default.conf /etc/apache2/sites-available/000-default.conf
COPY .env.prod /var/www/html/.env
RUN php artisan config:cache && \
php artisan route:cache && \
chmod 777 -R /var/www/html/storage/ && \
chown -R www-data:www-data /var/www/ && \
a2enmod rewrite
Let’s have a look at how the image will be built using this multi-stage dockerfile.
First off, we use the official composer 2.0 image as the build
stage. In this stage, we copy the whole application to /app
of the container. Then we run composer install with parameters like --no-dev
and --optimize-autoloader
which are well suited for a production build. The production stage doesn’t have composer as we don’t need composer to run our application, we need it to install dependencies only.
Consequently, in the next stage named production
, we start from the official PHP 8.0 apache image. After setting the two environment variables, APP_ENV
to “production” and APP_DEBUG
to false, we enable opcache with the following configuration placed at ./docker/php/conf.d/opcache.ini
:
[opcache]
opcache.enable=1
opcache.revalidate_freq=0
opcache.validate_timestamps=0
opcache.max_accelerated_files=10000
opcache.memory_consumption=192
opcache.max_wasted_percentage=10
opcache.interned_strings_buffer=16
opcache.jit_buffer_size=100M
Opcache improves PHP performance by storing precompiled script bytecode in shared memory. This means the same PHP sprint does not need to be loaded and parsed on each request. As it is a cache, it will speed up the response but it will be a problem if used in development as the changes won’t reflect until the cache is refreshed.
Subsequently, we copy the whole app and its composer dependencies downloaded in the build stage to the production
stage at /var/www/html
the default document root for the official PHP Apache docker image. After that, we copy the Apache configuration from ./docker/000-default.conf
to /etc/apache2/sites-available/000-default.conf
inside the container. The Apache configuration we copied in the container looks like below:
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/public/
<Directory /var/www/>
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Next, we copy the .env.prod
file that has the configs and credentials we need to run the application. We have used MySQL configuration from a database at Remote Mysql.
Test out the Dockerfile with docker-compose
At this juncture, we can test our docker file. A way to do it is with a docker build
command and pass lots of parameters. To make our lives easy, we will use the following docker-compose file and we can run docker-compose build
or docker-compose up
and not worry about remembering all the lengthy docker build parameters. Our ./docker-compose.yml
file looks like below:
version: '3'
services:
app:
build:
context: ./
volumes:
- .:/var/www/html
ports:
- "80:80"
environment:
- APP_ENV=local
- APP_DEBUG=true
Great! We have the docker-compose file ready too. We are using version 3 of the docker-compose definition. We have a single service called app
which builds from the docker file at ./
. We are adding all the files from the current directory to /var/www/html
this will sync the files. Next up we are exposing the docker port 80 to our local machine’s port 80. To debug things, we are setting up two environment variables APP_ENV
as local and APP_DEBUG
as true.
Before we build and run our docker container, let’s not forget about .dockerignore
.
Don’t forget the Docker ignore
Same as .gitigore
the .dockerigore
is also a very handy docker feature. Similar to git ignore file a docker ignore file will ignore files from the local machine or build environment to be copied to the docker container when building the container. Our small docker ignore file looks like below:
Depending on your need you can add more things to the docker ignore file. I will leave that decision up to you on what should not land up in the docker image. People tend to ignore the Dockerfile and docker-compose.yml too, it is a choice.
File changes in this pull request.
Build and run on prod mode locally
As we have all the needed files in place, we can build our production-ready Laravel docker container with the following command:
COMPOSE_DOCKER_CLI_BUILD=1 DOCKER_BUILDKIT=1 docker-compose build
It will give us an output that looks something like below after some minutes depending on your internet speed:
As the next step, we can check how big is the image that we just created with docker images | grep app
. In my case it was 457 MB compared to 732 MB for the sail one:
Of course, the image is not very small at 457 MB. Still, it is much smaller than the sail one. If your concern is the image size, it would be great to explore using alpine base images with FPM and serve the application with Nginx. For the scope of this tutorial, we will not venture into that path that has two containers.
As the container is built, we can run it with the following command:
It will give us the following output:
One important thing to note here is the database migrations have already been run on the database we are working on. In case they were not run, we would need to run the following so that the tables are created:
docker-compose exec app php artisan migrate --force
This will run the database migration inside the container. It can also be executed with a simple docker run.
We can choose from multiple ways to run this migration. As this is an idempotent action, we can run it as part of the start script of the container, but it would be better to put it as part of the deployment process with docker run
. If you plan to deploy this app on Kubernetes, the migration can be set up as an init container too.
Deploy it on Google Cloud Run
Creating a production-ready container and running it only locally would not be much interesting for us. So we will deploy our Dockerized Laravel Student CRUD app on Google Cloud Run. Cloud Run is a service to deploy containers in a serverless way. Yes, we can deploy containers that can scale up to 1000 instances without hearing the words Kubernetes and Pods. Below is a quick way to run our app on production:
- Make sure you are logged into your Google Cloud Account. If you don’t have one, get one with $300 credit for 90 days at $0.
- Go to https://github.com/geshan/laravel-crud-app
- Click on the “Run on Google Cloud” – that big blue button
- It will open up Google Cloud Shell
- Check the
trust
checkbox and then click confirm – image 09:54 - It might take a bit for the cloud shell to warm up, it will ask us to authorize the gcloud command, click
Authorize
- Then we will need to select the Project of Google cloud
- After that we will need to select the region, I generally go with
us-central-1
The process will look like below till now:
- It will take some time for the container to build and push it to the Google Container Registry (GCR)
- Consequently, it will deploy the container for us on Google Cloud Run using gcloud CLI.
- After the whole process is done, it will print the URL of our new cloud run service in green which ends in
a.run.app
. We can click it and see our app running on Cloud Run.
The process for the last three steps will look like below:
Then if we hit the service URL in green with /students
added to it we will see our Laravel App running on Google Cloud Run like below:
Congrats! There we have it, a Laravel app dockerized and then running on Google Cloud Run. It is time for you to explore Google Cloud Run a bit more.
Cloud Run is very simple and efficient in managing serverless containers.
Autoscaling, redundancy, security, HTTPS URL, and custom domains are some of the amazing features of Cloud Run you can surely leverage upon.
If you are interested in how it can be deployed so easily on cloud run, please do have a look at this pull request which uses the deploy to Cloud Run button.
Other things to consider
It is great that your containerized Laravel app is deployed on a Google cloud service without writing a single line of YAML configuration. Since this is a demo tutorial we can surely make it better. One of the things that can be much better is surely secret management with proper environment variables for better security.
Other things that can be better for performance are using Gzip compression and HTTP caching headers on Apache. Again these are things that will be for you to explore further.
Conclusion
We have seen how to dockerize a Laravel application for local development with Laravel sail. Then we re-dockerized the same application to be much more production-oriented. Finally, we deployed the app on super scalable and feature-rich Google Cloud Run which is surely ready for prime time. If Cloud run can handle IKEA’s workload it can surely handle yours, kudos to serverless containers.
Honeybadger has your back when it counts.
We’re the only error tracker that combines exception monitoring, uptime monitoring, and cron monitoring into a single, simple to use platform. Our mission: to tame production and make you a better, more productive developer.
Laravel News Links
Tying a Knot in Steel Rebar
https://theawesomer.com/photos/2022/03/steel_rebar_knot_t.jpg
Steel rebar is a stiff metal bar typically used to reinforce concrete. But like any metal, with enough force, you can bend it to your whim. Metalsmith Gavin Clark shows us a series of maneuvers he used to tie a length of 1/2″ rebar into a clove hitch knot. We’re impressed that he did it without applying heat.
The Awesomer
Mean Monday memes
True dat
https://blogger.googleusercontent.com/img/a/AVvXsEj9nzQoSlNuDi7OS4lJt0-2k1dy0NNqBESYWOX6PCE0Sph1FwXiVWDMxEq-uY7kbtWRZmujMTg67-0LxzU9_zrI8C2y8Lpv6Kg543r_obdREC5qx6z6YQvMk4OJMUzZXOnrzoX5Sbf3rRKw1oswvcN7kYZhsTOK26kVpHtjQTY11S7TR4LmpTJ1BvdQ=w361-h400
Found on MeWe this morning (clickit to biggit):
Based on very personal, very bitter experience in several Third World countries over many years, I’m here to tell you, that meme is exactly right. Civilized society and peaceful life, in the general context of human history, is indeed an anomaly that can – and frequently does – end at any time.
Imagine you were a Ukrainian couple in Kyiv this time last year. Would you have predicted the invasion of your country, the bombardment of your city, and the possible destruction of your home, your job, your schools and hospitals, and everything else that made up what was "normal" in your life? You probably wouldn’t . . . but welcome to 2022.
You say that can’t happen here, because the USA isn’t the third world? I have news for you. We’re importing the Third World by the millions across our southern border every year, with the blessing and permission of the Biden administration. More than two million of them every year (perhaps more; we don’t know, and we can’t trust the "official figures – it could be double that) are spreading throughout the USA like a cancer. They can’t help but drag down the societies into which they try to integrate, not out of malice, but because they don’t know any better. That’s not a racist statement; it’s cold, hard fact. Ask anyone who’s had extensive experience in the Third World (and I don’t mean staying in first world hotels in a third world capital; I mean boots on the ground among the people, with nothing to insulate them from the reality of that society).
Add that to the existing crime and violence problem in our cities, and things are going to get steadily worse in places like that. As I’ve said many times before, if you live in or near one of America’s big cities, you’ll be well advised to get the hell out of there as quickly as possible, before it’s too late – because the Third World is coming to your doorstep, and it won’t stop there. It’ll try to force its way inside your home, so you’d better have the means to stop it – or else.
Peter
Bayou Renaissance Man
Computer History Museum Publishes Memories of the Programmer for NASA’s Moon Missions
This week Silicon Valley’s Computer History Museum posted a PDF transcript (and video excerpts) from an interview with 81-year-old Margaret Hamilton, the programmer/systems designer who in the 1960s became director of the Software Engineering Division at the MIT Instrumentation Laboratory which developed the on-board flight software for NASA’s Apollo program. Prior to that Hamilton had worked on software to detect an airplane’s radar signature, but thought, "You know, ‘I guess I should delay graduate school again because I’d like to work on this program that puts all these men on the Moon….’" "There was always one thing that stood out in my mind, being in the onboard flight software, was that it was ‘man rated,’ meaning if it didn’t work a person’s life was at stake if not over. That was always uppermost in my mind and probably many others as well." Interestingly, Hamilton had originally received two job offers from the Apollo Space Program, and had told them to flip a coin to settle it. ("The other job had to do with support systems. It was software, but it wasn’t the onboard flight software.") But what’s fascinating is the interview’s glimpses at some of the earliest days of the programming profession:
There was all these engineers, okay? Hardware engineers, aeronautical engineers and all this, a lot of them out of MIT… But the whole idea of software and programming…? Dick Batten, Dr. Batten, when they told him that they were going to be responsible for the software…he went home to his wife and said he was going to be in charge of software and he thought it was some soft clothing… Hamilton also remembers in college taking a summer job as a student actuary at Travelers Insurance in the mid-1950s, and "all of a sudden one day word was going around Travelers that there were these new things out there called computers that were going to take away all of their jobs… Pretty soon they wouldn’t have jobs. And so everybody was talking about it. They were scared they wouldn’t have a way to make a living. "But, of course, it ended up being more jobs were created with the computers than there were…." Hamilton’s story about Apollo 8 is amazing…
Read more of this story at Slashdot.
Slashdot
Wirecutter, is that you?
https://gunfreezone.net/wp-content/uploads/2016/01/cropped-gfz-ico.png
Gun Free Zone
Officer cleared in the shooting of Ma’Khia Bryant.
https://gunfreezone.net/wp-content/uploads/2022/03/MaKhia-Bryant-shooting-officer-cleared-alt.jpg
I am sure you remember this case from last year:
The officer has been cleared of any wrongdoing (and rightfully so), but two things keep popping up that tick the hell out of me. First is the “Trayvonization” of Ma’Khia Bryant. By that I mean she is literally portrayed in image as a peaceful happy child rather than the violent woman armed with a knife, half a second away from inflicting a deadly injury to somebody unarmed and non-aggressive. Just like to this day the image of Trayvon Martin is of that cute 12-year-old in a white hoodie rather than the late thug teen smoking and flipping the bird to the camera acting all gansta.
All the media outlets I checked have managed to keep the racial component out of their wording. No need for them to add anything since there are plenty of people in the comment section adding it. And then, there is the second part that ticks me off: Those Internet experts in the Use Deadly Force graduated from the University of TV Shows and PHD From the Jackie Chan Disarming Program.
I just would like to ask these idiots one simple question: How many stabs to the abdomen and chest would they be willing to take as long as the cops use “dialogue” and taser (with a 50% failure rate) on their attackers? One? Five? As long as it takes? Till the coroner picks up their body?
Inquiring minds want to know.
Gun Free Zone
One of the best-equipped and most experienced “preppers” I’ve ever encountered
https://blogger.googleusercontent.com/img/a/AVvXsEipknX1Ei8MMkWoR9BhGNENvvUlRqbx83zLfzavZWcrSfm5XgZ3-h3UKlHNpjXafiWDSnhaGxmYe9hZycZFhpDfH0xDjo6xu-39G1tX0nGD1AQ08WxpsXzp4o9cp-344SvZaGSiezXaDqPp6D_oGE1JRDuYqqSRCQ3yPnCvXpcIONk7p56Z0NlVfV0W=s72-c
We’ve spoken often about the need to make preparations for emergencies before they happen, and particularly in the current economy (which is enough of an emergency in itself, thank you very much!). After I published another article about that recently, an online friend I’ve corresponded with over several years sent me a long and detailed e-mail about his emergency preparations. Frankly, I’m very jealous of his stash (although "hoard" is probably a better term, in the sense of dragons hoarding gold, as depicted in fiction). It’s certainly worth a great deal of gold in today’s economy.
In order to illustrate how well prepared you can be, if you work at it, I asked him for permission to reprint his e-mail here. He agreed, as long as he wasn’t identified or his location given; so, here’s "my older friend in the mountains".
Hi, Peter,
I saw your post this AM, thought I might chime in with a couple things. You probably already know most of this, but maybe some of it might be useful.
I’m extremely fortunate in that I began prepping a long, long time ago (when I moved to my present location about ten years ago one of my friends helping load the moving truck said – while loading a large stack of heavy boxes that had a "certain rattle" to them – "I bet they have stores in your new location that sell canned food, too."). I currently have about 1500 cans of food on hand (FYI, a 12"L X 9"W X9"H box holds 24 cans, each 16 ounces, with space between them for plasticware – knives, spoons, forks – with P38s and P51 openers taped under the box lid, 8 cans of protein, 8 of vegetable and 8 fruit, makes a "food unit"; I don’t keep canned fruit over 6 months past it’s "best buy" date because meat and veggies are cooked before canning but canned fruit in my experience will start leaking soon beyond six months after that best buy date) plus 250 cases of freeze dried food, about evenly spit between Mountain House and Augason farms; there’s 300 gallons of drinking water in 5 gallon jugs, 5 Big Berkey filters with 2 sets of spare filters for each, a pair of 250 gallon water tanks to capture "flushing and irrigation water" from the roof gutters, 1,000 large coffee filters to screen "stuff" from water, over a dozen Sawyer and LifeStraw personal water filters, 4 methods of making coffee from a Mr. Coffee to coffee presses to two old fashioned percolators and a simple "funnel & filter drip" method.
I won’t mention ammunition, firearms or magazines because, well, gosh, who would need any of that? The tires on the truck are 12 years old but still in good shape and just past half-worn (it’s garage kept so no sunlight damage), I have 4 new tires (3 years old) mounted on spare steel wheels (one pair gets pumped up from 4 PSI to 30 PSI and has snow chains installed every November to April, just in case we get ice. It’s faster and easier to swap wheels than install chains in the snow, especially with a cordless ½ inch impact driver) and there’s a stack of 6 brand new tires bought recently on sale under a tarp in the corner of the garage waiting to be mounted. I have 10 NATO cans with non-ethanol gas that gets rotated – every few months I’ll refill the truck tank with 10 stored gallons and refill the cans, using Pri-G fuel stabilizer so the stored gas is never over 12-15 months old (Pri-G is great stuff, BTW, Commander Zero recommended it so I tried it, and my "test case" was non-ethanol gas stored for 3 years in 2 NATO cans with Pri-G and it was fine). I have 4 empty NATO cans on the shelf and 12 more in the garage attic (4 were "surplus, stored" on sale from Coleman Outdoors – covered in dust and dirt from storage but never used so the inside is pristine; I got them cheap so those are my "giveaway cans" if someone is in dire need). I was lucky to buy all those cans 12-18 years ago when they were much less expensive. I know they’re very expensive now, but the real NATO cans, now made in Latvia, are the only way to go; the cheaper knockoffs just aren’t the same. I will refrain from commenting about the CARB-approved spouts that are mandated now except to say that once government gets involved nothing improves.
FYI, if you get NATO cans get several extra NATO spouts – nothing else will fit the cans, and the regular spouts will need to be modified – this if for the old style, pre-CARB spouts, haven’t tried it yet on a CARB spout – I removed the rubber flexible section and installed 16 inch length of 1” ID clear plastic tubing from the home center plumbing dept. and a 1” male-threaded-to-3/4” ribbed nipple fitting; now the end fitting will reach ANY gas filler, fit unleaded fillers and 20 liters of gas empties in 50 seconds. Pro Tip: use safety wire wraps or screw clamps to secure all the parts together so nothing comes apart -you absolutely do not want the hose coming off the nozzle or getting loose and leaking when you’re pouring gas.
In the truck I’ve got two 30 ft Nylon tow ropes, tree straps and a couple 20 ft "trucker chains," a bunch of 5 ton steel shackles and "soft shackles," (soft shackles are much more expensive but a whole lot safer) two 4000 lb and one 6,000 lb comealongs in the garage, two high-lift off road jacks, a 2 ton and a 3 ton scissors jack, a 3 ton, 5 ton and a 20 ton hydraulic jack, double thickness 3/4 plywood "jack plates" for soft soil (I used to live where you either put something large, solid and flat under a jack or you just drove the jack into the ground – Pro Tip here – two pieces of 3/4 plywood glued together with polyethelyne glue – Gorilla Glue – cut to the largest size that will fit under the passenger seat (mine are 17” wide X 19” long), with 3/8" holes near each corner for anchoring with 12" landscape spikes and holes for bolting the high lift jack to the plate will save the day. Make THREE double 3/4" plates, two will probably fit under the seat and worst case, put two together right against each other with the third across the top for the jack. I got a friend’s high-centered 4X4 GMC out of mud once with that trick).
Plano Plastics makes heavy duty 56 quart “cargo boxes” (Walmart, Amazon, etc.) that will hold a lot of stuff, not waterproof but will stay dry in the rain, put them in the bed and strap ’em down. I’ve got a couple Marine versions (gasketed lids), one is the “Road Box” with food, water, cooking equipment, blankets, rain gear, etc. the other is the “Unstuck Box” with an extra tow cable, hydraulic jack, extra soft shackles, a tree saver strap, etc. If I’m going farther than I think I can walk back from, those go in the truck. There is already a very good assortment of general mechanical tools under the back seat, and I never, ever, venture outdoors without a large diameter projectile expeller on one hip and a Tube of Dark Repellent on the other (I really like Elzetta lights, but Surefire and Streamlight are good, too, it’s just that Elzetta allows you to custom build a tactical light the way you want it.).
Since COVID hit and drove freeze dried food prices through the roof I’ve stopped buying FD food, shifted to more readily available canned and dry food and spent the last 2 years wracking my brain about the multitude of less obvious stuff – nails, screws, light bulbs, extension cords, lumber, rope, clothing, shoes and boots, home repairs and upgrades, spare roof shingles, 2X4s, batteries (I’ve bought only lithium batteries (AA and AAA) for the past 2 years), spare parts, etc. etc. and have added to those supplies as availability and budget allowed. For almost 3 years I’ve basically spent every dollar I had that wasn’t committed to something on "prepping supplies."
A year after I bought the house I’m in now I had it converted to "dual fuel" – it had an electric heat pump so I paid the local utility $350 for the gas line hookup and replaced the heat pump air handler and backup electric heat with a natural gas furnace (I can control the switchover at the thermostat – air-to-air heat pumps lose a LOT of their efficiency below about 38F so I’ve got it set to stop using the heat pump and switch to using NG below 40F), plus a natural gas tankless water heater – the NG furnace draws 865 watts on 120 volts to operate, the NG tankless water heater draws 92 watts and the UPS it’s on (an APC 1500) protects it from surges AND will power it for 3 weeks of 2 4-minute showers/day (both the furnace and water heater can be converted to propane if it comes to that) so I can power the NG furnace (and the NG water heater) with a Honda EU2000 generator. I have a propane fireplace and as soon as I can find the one I want for a price I can afford, I’ll install a standalone propane heater to sit in front of the fireplace and connect it to where the propane logs connect because the heater will be much more efficient; there’s 200 gallons of propane in two 100 gallon tanks (2 is one, 1 is none….) outside and I get them topped off twice a year. If I can, and I doubt it will be possible now, I’ll replace my electric stove with a propane stove so I’m self sufficient for cooking (FYI, natural gas is about 1050 BTU per cubic foot, propane is just over 2500 BTU). I do have 3 Coleman camp stoves, 2 kerosene cook stoves, 2 propane burners (previously used turkey fryers I got from a thrift store), some firebrick to make a rocket stove and 4 propane/butane single burner units, and 3 “camp-out style" cooking grates that will work over any fire.
I’ve accumulated quite a few pieces of cast iron cookware, some inherited, some purchased, and 2 sets of "budget cheap-o stainless cookware" that I won’t mind using over a wood fire (or gift one to someone in dire need). I’ve got 4 propane heaters (all of them Mr Buddy heaters, the largest rated at 80,000 BTU) and five 40 lb propane tanks plus the 20 lb on the grill and a spare 20 lb. Seven Aladdin lamps, one of which is wall mounted, 2 kerosene heaters (one 23k BTU vertical convection, one 50K BTU fan forced,which also requires 120 volts to work) and 25 gallons of kerosene in NATO cans. Six railroad-style kerosene lanterns, and a pair of Bryt-Lyte German pressure-fed liquid fuel lanterns that will burn ANYTHING that’s liquid and flammable. I have 44 Stanley parts organizers in a cabinet in the garage filled with small parts and supplies, another 12 in the “South Warehouse” filled with gun parts. I’m a gear head who worked his way through college in the motorcycle business and have rebuilt V-8s and manual transmissions and more motorcycle engines than I care to remember so I already had a good supply of mechanics’ tools and quite a few carpentry tools. My family owned a 200 acre farm that from my late teens into my thirties I was the "maintenance manager" for, so I inherited, bought and accumulated quite a few "manual labor" tools because extension cords wouldn’t reach 2000 feet to the back fence. Learned a lot doing that, turning sweat into knowledge.
Pro Tip here – I installed two whole-house surge protectors (and yes, I used a very experienced licensed electrician even though it cost money), one a Siemens unit in the outside meter box where the power lines come in and a Square D in the distribution panel indoors (indoors, I can shut off the main power outside, and have, to swap breakers or install the surge protector, but, sorry, I’m not going near the high amperage lines feeding into the meter because there’s no way to make them “cold.” I do know my comfort zone and my limits.) There is a large possibility that electrical power, however it’s produced, will be unreliable in the future and power drops and surges could easily occur. It would be unpleasant in the extreme to have a surge kill your refrigerator, especially when it might take weeks or months in a supply shortage to get a new one; that’s personal experience talking, make of it what you will.
I gave up my guest room 3 years ago, it’s now the "North Warehouse" and the spare bedroom next to it is the "South Warehouse" – both are full of wire rack shelving with barely room to move in either room. Part of my plan has been to have enough supplies to support not just myself but a few others who may be in dire need AND WHO HAVE PROVED THEMSELVES BOTH WORTHY AND TRUSTWORTHY. Whatever I give out won’t come free, it will have to be earned by the recipient demonstrating he or she is worthy of it; until then I’m Sgt Schultz on Hogan’s Heroes about prepping – "I know nothing."
I’m on a good sized lot in a semi-rural location but don’t have enough space to grow much of anything, and what space I do have is too heavily shaded in summer, but a friend lives a moderate distance away on rural acreage and I’ve lent some of my brawn & brain to helping him so that is a potential source of future food, and a potential "bug out location." That will mean sleeping in the barn, probably, but I can make a pretty good bed out of freeze dried food cases and I have sleeping bags, wool blankets and a couple military sleep systems (I also have a cheap Chinese tent stove, so worst case I can produce some heat…). I’ve also got a couple 2-person tents, just in case, and it’s vitally important that should it develop that bug-out be required I will not show up empty handed, I’ll arrive with as much food, supplies and equipment that the truck can carry.
I’ve kept $5K cash in an emergency fund while spending almost everything else, but given what happened in Canada I’ve started cleaning out the bank account every month with whatever is left after bills are paid and keeping it on hand in cash. I’ve also opened a second set of accounts at a local credit union because while it probably won’t fare any better than the mega bank where my main accounts are in the event of punitive government action it does provide additional options. I absolutely, positively do not trust our government to not follow Canada’s example. I have not bought any "junk" silver since the price went above $20/ounce and was lucky enough to be paying *very close* attention when it was in the $12-$16 range, which is all I’ll say about that. I see no need for having a lot in the way of gold because the smallest denomination is too large for everyday use, but having some can be handy (I consider firearms, ammunition, especially canned food, spare parts and supplies, and very especially knowledge, skills and willingness to work, much better for bartering purposes, but bartering is high risk so I look more at that as “supplying assistance to those whom I trust who are in dire need.”
As a young kid – age 5 through 7 – my cousin and I (we’re the same age and both of us were "city kids") spent much of our summer on Grandma’s farm (part of which I inherited years later). Once a month we’d head to the "big city" 35 miles way ("big city" meant a population of 10-12,000) for a shopping trip, the rest of the time we made or grew it ourselves, improvised or did without. I didn’t appreciate it at the time but that was an education that has returned full value for my entire life.
There’s no question in my mind that I have been blessed beyond belief and human understanding. I have no idea why or to what purpose, I assume I’ll find out when I need to know.
Peter, you mentioned buying a generator to power the house; some years ago I went through several hurricanes and a tropical storm in a couple months. With the first one we lost power for 6 days, the other two killed power for about a day or so each. Fun times, let me tell you. I had a Honda ES6500 generator and a Honda EU3000i generator. When I lived in the mountains we had well and septic and being in the mountains we lost power from snowstorms, ice storms and strong thunderstorms and I needed 240 volts with 30 amps to run the well pump. I got the ES6500 because it was 120 / 240 volts. 52 amps, and electric start, which made it possible for others to start.
Honda built that generator with a 359cc 2-cylinder water cooled car engine (cars in Japan are taxed based on engine size, the one that uses the 359cc 2-cylinder is a tiny 2-person "car" no larger than a US golf cart). AFAIK, Honda no longer offers that generator, replacing it with a 7000 watt super-quiet air cooled generator. I’m trying to find budget dollars to replace the 6500 with the newer super quiet 7000. The ES6500 can run for DAYS as long as it’s kept fueled – it’s a car engine, after all, water cooled, large oil capacity, spin-on oil filter, etc. but I doubt I need days of run time now.
I got through the hurricanes with the Honda EU3000i; the fuel tank is 3.4 gallons and I powered the refrigerator and some fans (daytime) with it and the fridge and a window air conditioner at night, about 14-16 hours total run time on about 2.5 gallons. The 3000 is 120 volts only so it won’t power 240 volt equipment. Other than well pumps, that’s not too big a deal – electric water heaters can be "adjusted," central AC and heat pumps need 20-30,000 watts, so a MUCH bigger generator is required. Honda calls for oil changes on the 3000 at – IIRC – 40 hours. I use nothing but high grade synthetic Amsoil in it and was religious about changing it at 60 hours.
What I did – my older house in the mountains came with the usual ”builder grade” 6 gallon draw down well pressure tank so the pump started, stopped, started, stopped, etc. I replaced the small tank with 2 larger tanks, each with 46 gallon draw down. I plumbed in for 3 tanks, could only find 2 readily available of that size. The result was the pump would run for about 13-15 minutes to refill both tanks then shut down. I replaced shower heads with very low flow heads (1.5 GPM) and taught the family about "navy showers" when we lost power. We had the old 4.5 gallon per flush toilets, I replaced one with a new 1.6 gallon (it was lousy because it was very early in the government-forced toilet conversion, they’re much, much better now) and taught "yellow, let it mellow, brown, flush it down" so we could get through 12-15 hours without having to fire the generator up to refill the draw down tanks. 1-3 long pump runs daily was easier on the pump and the generator. I won’t go into detail about how I connected the generator to the house, but I did have a 50 amp circuit with receptacle in the basement for a welder. If going this route you really, really, really need a transfer switch, even a manual one, installed by a qualified and licensed electrician. It also pays to have heavy duty cords – I made two 125 ft cords, one with 10-3 SO cable (30 amp) and one with 8-3 SO (42 amp) to handle both 120 volt power legs and neutral and one 100 ft with 8-4 (both power legs, a neutral and a ground, for a 4-slot twist lock welder receptacle, uh, well, just in case I need to power the welder…..)
People tend to buy larger generators than they need. If you have to power a well pump you’ll need 240 volts at 30 amps or better, but for normal household stuff, 120 volts with 2500-4000 watts will do it. The larger the generator the more fuel it requires and fuel will be the #1 issue in SHTF situations.
I was able to provide some hot water – I had an 80 gallon electric water heater – 240 volts, 30 amp circuit, two 5500 watt heating elements. I replaced one of the 5500 watt heating elements with one of a lower wattage and modified the system from the breaker panel to the water heater to allow powering only one heating element, trying to power both would exceed the total wattage available from even a 6500 watt generator (the thermostats in electric water heaters “flips” power between the upper and lower heating elements, powering only one at a time; running even one 5500 watt element would be just under the rated 6000 watt maximum steady draw for the generator, and while both elements SHOULDN’T be powered by the thermostats at the same time, doing so – even for a very brief period – would quite severely overload the generator and I did not want to risk damaging it). Doing this involves advanced electrical knowledge and is very much a non-standard installation, so hire a highly qualified licensed electrician who has experience in this area. FYI, it is possible to run an electric water heater element on 120 volts but efficiency falls off a lot (don’t ask how I know). Again, hire a very qualified licensed electrician for any of this; working with electricity is hazardous and long time licensed electricians should know how to do it.
I could run the generator for about 15 minutes to fill the draw down tanks, then switch the pump breaker off and the water heater on to heat water for about an hour, then shut the generator off. Heating 80 gallons with only one lower wattage element takes a while, and I’d suggest reducing the water temperature by adjusting the thermostat control for the one element that’s receiving power; 120-125 degrees is nice and toasty for showers and laundry, but you can get by with 100-105, and yesterday would be a good time to add extra insulation to your water heater. The best solution would be a propane-fired tankless water heater and had I stayed in that house I would have spent the money and gotten one installed. It was high on the list for this house soon after I moved in, but natural gas was cheaper and readily available.
Pro Tip – Don’t do a “dedicated laundry day.” It’s handy, and maybe more efficient, to do all the laundry in “batch mode” on one day per week, but if SHTF – or your area is subject to random power outages….. your capacity to run the washer, and/or heat water, will be very limited. If the poop strikes the impeller having a large pile of dirty laundry to process will be an “issue.” Instead of batch mode do “continuous flow” – if you have enough to run a load, even a small one, do it. Worst case, you’ll need something other than the dryer to dry it. And have enough clothesline rope on hand to dry it, do it. Fence posts are set on – usually – 8 ft centers, I cut brackets out of 5/4 (standard decking boards), bolted them to fence posts, drilled and strung clothesline through the brackets. Presto – 96 feet of drying clothesline along the back fence. I don’t use it all that often, and it won’t work on rainy days or when it’s below freezing, but the rest of the time it works fine.
For 120 volt needs I used the 3000 because it was MUCH quieter and more economical on fuel – fridge, whole house fan (summer), window AC at night, oscillating fans (summer for comfort and winter to spread the heat from the wood stove), the 120 volt stuff on extension cords. I have lots of 12 and 10 gauge 50ft and 100 ft cords, Tripp Lite makes 15 and 20 amp multi-outlet strips with 15 ft and 20 ft cords. During the hurricane power outages the 3000 did the same work.
Pro Tips: test your fridge – get a wireless fridge & freezer thermometer (Amazon, about $35) set freezer to max cool, the fridge to "max cool without freezing stuff" and let it stabilize for 24 hours, then unplug it and DO NOT OPEN THE DOORS. Watch it for temp rise, when fridge temp gets to about 46-48F plug it in and see how long it takes to get back down to 33F. It will continue to rise beyond 48F for 30-60 minutes before temp starts dropping. The freezer probably will not go above 10F. That time – 33F to 48F is how long it can go without being powered up, the return trip down to 33F is how long it needs power to cool down. My fridge would handle 7 hrs off / 2.5 on so I did 6 off / 3 on during the day; the 3000 ran most of the night to power the fridge and a window AC because having a cool room to get 6-7 hours restful sleep makes it possible to get through the day without accumulating exhaustion (if you were ever a field troop in the military you know all about accumulating exhaustion and how it impacts physical and especially mental performance).
That DO NOT OPEN THE DOORS thing will require training family members. Especially teenagers. The fridge doors get opened only when the fridge has cooled down and the generator is continuing to keep it cool. That will not be an easy or simple training procedure but it can be done. A cooler for drinks, sandwich stuff, etc. will turn out to be handy. So would handcuffs and leg irons, but…
I thought about buying insulation panels – iso foam is R 6.5 / inch, so adding a 2" layer of insulation is R 13 – to the exterior sides of the fridge (and now, my chest freezer) to buy more "off time" between generator runs but have not done it. Yet. I need to research that and see if it’s actually worthwhile. It should be, but I want to see some real data on it. There are ultra efficient refrigerators and freezer – Sun Danzer is one brand I’m aware of but there are several – that usually run on 12 volts to make it easy to power them with solar panels, and have several more inches of insulation than regular fridges and freezers. They’re not cheap, almost always in chest style and nowhere near the size of a regular home refrigerator, but if I had the space I’d get two, one freezer and one refrigerator. Propane fridges work but I don’t know enough about them except that they seem to consume a lot of propane; I need to do more research.
I used brand name all-copper extension cords and the Tripp Lite power strips during the hurricanes to distribute 120 volts from the 3000; the Tripp Lite strips aren’t cheap, $30-45 each back then but worth it. The cheap stuff from home centers and online just don’t cut it, they’re frequently copper-clad aluminum (especially auto jumper cables). Avoid those, go with pure copper. More expensive but worth the extra $$.
During the hurricanes I had a 30 inch industrial fan I had bought from a dry cleaner going out of business (replaced the bearings, belt and motor – originally it moved 9000 CFM and drew 480 watts, when I was done it moved 4200 CFM on 240 watts). I grew up in a large city in the early 1950s in an older apartment building; no one had AC then, everyone had a 20" 3 speed paddle-bladed window fan in the kitchen window that never got shut off from April to October (those fans were everywhere back then but are “antiques” or “vintage” now and sell for $200 or more….). By opening the right windows and doors air flow through the apartment could be "regulated", especially to flow over the beds at night. I did the same thing with the 30" industrial fan and used several 16-20" oscillating fans with 25 ft 14 gauge extension cords to keep air circulating in the dead spots. It was warm, humid air but it was moving warm, humid air.
The EU3000i is ultra quiet – sitting in the back yard no one knew I had a generator running. That meant it didn’t attract generator thieves, or keep the neighbors awake. The ES6500, well, it is very reliable, but stealthy it ain’t.
I loaned the 6500 to a neighbor, when they had it running it sat in the driveway of their house powering their fridge and a couple fans and with extension cords running to the refrigerators and a couple oscillating fans in the houses to either side. They had to rush out and buy gas cans, gas, fans and extension cords. In the mountains we had a 120 volt whole house fan that…uh…."could be powered." I won’t say how. FYI, DO NOT run a generator indoors, not even in a garage with the door open or on a carport. Gasoline engines produce carbon monoxide (CO) and every year during power outages people die from CO poisoning caused by generators – CO attaches itself to hemoglobin in blood easier than oxygen does and prevents oxygen from attaching to hemoglobin, the result is no oxygen gets distributed through the bloodstream and death comes quickly. The body will tell you when there’s too much Carbon Dioxide (CO2) in the bloodstream or lungs – hold your breath for a while, you’ll see – but that reaction isn’t present for Carbon Monoxide. Just DO NOT RUN ANY CARBON MONOXIDE PRODUCING EQUIPMENT ANYWHERE INDOORS OR NEAR INDOORS.
My current house doesn’t have a whole house fan so I bought a 20 inch Air King "whole house window fan" from Amazon – 3 speeds, 1700 – 3400 CFM, it brings me back to my childhood days in the big city apartment opening the right windows and doors, but it works, and I have several 16" oscillating fans and a 22" and a 24" oscillating pedestal fans from Northern Tool. It takes a very large generator to run central air conditioning, so figure on fans, they can be run with a low wattage generator. Look for sales on fans in late summer/early fall and stock up.
I now also have two Honda EU2000i generators (bought one some years ago, the other came as a gift). They’re ultra quiet and like the 3000s, can be coupled together with either Honda’s wiring kit, or a home built wiring kit, to double the wattage; again, this requires advanced electrical knowledge so consult with a licensed and very experienced electrician or just buy the Honda kit. The new ones are now rated at 2200 watts. Still always 120 volt, but going to 240 volts is expensive; unless you really need 240 volts for something I’d stick with 120V in a high quality quiet generator (I like the Hondas because I have experience with them, but there are several other comparable manufacturers). The Cheap-O $500 generators from home centers and big box stores etc. often will output 240V but they’re built with – usually – inexpensive engines, although some use the Honda air cooled engines which are very good, but they’re all noisy, even the Honda engines, and use more fuel. They’re also usually not designed for prolonged continuous use.
The Honda 2000s (now they’re 2200 watts) have a small fuel tank – 1.25 gallons – so as economical as they are they’ll still need refueling more often, the RV crowd has a way of getting around that with an auxiliary tank arrangement (just search "RVs and Honda 2000 generator extra tank"). A pair of new 2200s will be less than one new EU3000, they can be coupled together, most of the load you’ll be applying will be 120 volts and less than 1600 watts, for loads above that use both generators and the coupling kit, but most of the time one EU2200 will do the job. And, you have "2 is one and 1 is none." My EU3000 is 158 pounds (some of which is because it also has an electric starter, which I needed back then, and the new ones are lighter), my EU2000s are just under 50 pounds each, and one can be powering stuff while you’re changing oil in the other.
Get lots of extra oil, Honda calls for oil changes every 24 hours of use on the EU2000s. I ran my EU3000 for 60 hours between changes, but I use nothing but very high grade synthetic oil (Amsoil) in everything and was religious about not exceeding that time limit. Pro Tip – Get lots of extra oil anyway. It’s going to be more expensive and harder to get so get plenty now, you’ll need it. Don’t forget filters too (oil AND air), and spare drain plug gaskets is a good idea, too.
During the hurricane power outages I used my propane grill for cooking and making coffee (although the EU3000 would power the 1800 watt electric coffee maker, it wasn’t happy about it….), I still have the same grill, plus the other heat sources I described earlier. Multiple heat sources is good, develop them if you haven’t already.
During the hurricane power outages we never lost county water and it was late summer, so cold water from the spigot was 82-84F. I did have a Zodi water heater (look it up on the internet) which I used a few times, but most of the time 82F from the shower head was tolerable. Here we have winter (I’m back in the mountains again) and the water temp gets as low as 48F, so I’m keeping the Zodi handy. FYI, just like gasoline-burning generators, propane-burning water heaters like the Zodi produce carbon monoxide (CO) so DO NOT use them indoors. One trick is a 5 gallon bucket – on camping trips I’ve put both the pickup and spray head in a bucket and let the battery powered pump recirculate the water heated by the Zodi until it’s warm enough, then shut the propane burner off and remove the 1 lb propane cylinder and take the Zodi and the bucket of hot water indoors to shower with. It’s more work, but I know how dangerous CO is and I refuse to take risks with it.
One thing I strongly recommend, and with your military and prison work background you’re probably aware of it, is to perform a SWOT Analysis – Strengths, Weaknesses, Opportunities and Threats – to examine in detail where you are, where you need to be and what’s the delta between those points. A good SWOT Analysis is not a simple, or short, task but a very worthwhile one.
There’s lots more, but this is too long already. If I think of more that’s important enough to bother you with I’ll send another email. And, I apologize for the typos. I was typing fast and I didn’t run spell check on it.
(signed)
Your Older Friend in the Mountains
I’m green with envy at his extensive supplies and preparations. I hope and pray he never needs them; but, if push should come to shove, I bet he’ll be a lot better off than almost anyone in his area (not to mention his entire state!). If Miss D. and I find ourselves trapped far from home, but near him, when an emergency arises, I daresay he might receive an emergency e-mail asking for sanctuary.
So . . . how do your preparations compare to his, friends? Mine can’t hold a candle to them. (Note to self: check candle supplies, add to shopping list . . . )
Peter
Bayou Renaissance Man
Playing a Water-filled Piano
https://theawesomer.com/photos/2022/03/filling_a_piano_with_water_t.jpg
“I know this looks bad… but I’m doing it for the sake of science.” Mattias Krantz likes to do some crazy and borderline sacrilegious stuff to pianos. In this clip, he took an old piano, waterproofed it, then filled it with bucket after bucket of water to see what it would sound like when its strings and soundboard were submerged.
The Awesomer