Get Started
Let's create a Meteor project and then see how we can dockerize it using Docker.
Step 1 - Install Meteor
Symfony utilizes Composer to manage its dependencies, similar to Laravel. So, before using Symfony, make sure you have Composer installed on your machine.
Install Composer
- OSX / LINUX Run the following command in your terminal to install the latest official Meteor release:
$ curl https://install.meteor.com/ | sh
- WINDOWS First install Chocolatey, then run this command using an Administrator command prompt:
$ choco install meteor
The installer uses Chocolatey, which has its own requirements.
Step 2 - Create a Meteor Project
You can create a meteor skeleton project by issuing the meteor create
command in your terminal:
meteor create meteor-tutorial
Then, to install all dependencies and run the project, you need to run the following commands:
$ cd mutual-tutorial
$ meteor npm install
$ meteor
You will see your Meteor server running on: http://localhost:3000
Congratulations, you’ve created a Meteor project!
Step 3 - Dockerize the Project
Setup Docker
Before creating a container for the Meteor application and shipping it off, you need to install Docker on your local machine. For learning purpose, you will install Docker Community Edition. Select your OS from the list below and follow the setup instructions:
Make the docker App image
The next stage is adding a Dockerfile
to your project. The structure
of a Dockerfile
can be considered a series of instructions on how to build your container/image.
Start the Dockerfile by creating an empty file named Dockerfile
in the root of your project. Then, complete each
instruction according to the following example:
# Dockerfile
FROM node:6.9
ENV METEOR_ALLOW_SUPERUSER=true
ENV ROOT_URL="http://localhost:3000"
RUN curl "https://install.meteor.com/" | sh
COPY . /usr/src/app
WORKDIR /usr/src/app
RUN chmod -R 700 /usr/src/app/.meteor/local
RUN meteor npm install
EXPOSE 3000
CMD ["npm", "start"]
Building and Running the Container
Building the container is very straight forward once you have Docker and Docker Machine on your system. The following
command will look for your Dockerfile
and download all the necessary layers required to get your container image
running. Afterwards, it will run the instructions in the Dockerfile
and leave you with a container that is ready to
start.
To build your meteor docker container, you will use the docker build
command and provide a tag or a name for the container, so you
can reference it later when you want to run it. The final part of the command tells Docker which directory to build
from.
$ docker build -t meteor-tutorial .
The final step is to run the container you have just built using Docker:
# $ docker run -it -p 3000:3000 meteor-tutorial
The command tells Docker to run the container and forward the exposed port 3000 to port 3000 on your local machine. After you run this command, you should be able to visit http://localhost:3000 in your browser.
You can see the Docker containers that are currently running on your system (along with their Container IDs) with:
$ docker ps -a
To turn off your Docker container, run:
$ docker stop container_id
Push to cloud
1. Create your app
In order to install your docker php example, just create a new app via cli or admin panel and set a port to 8000.
2. Push your docker container
3. Set up resources
4. Logs and app status
5. Release your app
After to click on the release button, your php docker tutorial will be deployed, Just click on the generated URL and you will get your app running.
Now you can deploy your Meteor app without a massive build time.
Bonus 1: SSL certificate for HTTPS
It's already done for you. If you need to connect your custom domain, SSL certificate will be provided for it.
Bonus 2: Autoscaling
With autoscaling the app will be scaled up when CPU and RAM load goes up and scaled down when it goes down.
Now you can deploy your Meteor app without a massive build time.