Skip to content

Instantly share code, notes, and snippets.

@mschipperheyn mschipperheyn/Dockerfile Secret
Last active Apr 3, 2018

Embed
What would you like to do?
Getting a Reaction Commerce development server up and running the cloud using Docker

Read me

The shell script contains the docker-machine command to create a machine in the cloud The Dockerfile creates the Reaction Commerce server The docker-compose file (is supposed) to create a deployed system that includes a remote mountable file system based on SSFHS (https://github.com/vieux/docker-volume-sshfs)

Please make sure you set up your aws credentials, e.g. by placing them in ~/.aws/credentials

[default]
aws_access_key_id = XXXX
aws_secret_access_key = YYYY

You can setup the key_id and access_ke in the AWS console under IAM

Make sure you put any variables you define in docker-compose.yml in an .env file, in this case: GIT_URL=SOMEUSER:SOMEPASS@github.com/project

which represents the GIT URL from which to retrieve your dev project

#!/bin/bash
# Make sure you add your id_rsa key to ssh-agent: https://help.github.com/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent/
AWS_ACCOUNT_ID=XXXX
NAME=reaction-dev
VERSION=0.1
EB_BUCKET=reaction-images
REGION=sa-east-1
AMI_ID=ami-423d772e
KEYPAIR_PATH=~/.ssh/id_rsa
# Build image
docker build -t $NAME:$VERSION .
# Create a new application version with the zipped up Dockerrun file
docker-machine create --driver amazonec2 \
--amazonec2-region $REGION \
--engine-label "$NAME-$VERSION" \
--amazonec2-instance-type "t2.nano" \
--amazonec2-ssh-keypath $KEYPAIR_PATH
$NAME-$VERSION
# Now any command after this will be executed as if on the machine
eval $(docker-machine env $NAME-$VERSION)
docker-compose build
# This docker-compose file is used to run the reaction app in docker for development
# The local files are mounted into the created container.
# Usage: docker-compose up [-d]
version: '3.4'
services:
reaction:
build:
context: .
dockerfile: Dockerfile
args:
GIT_URL: ${GIT_URL}
target: meteor-dev
command: "reaction --inspect"
depends_on:
- mongo
environment:
ROOT_URL: "http://localhost"
MONGO_URL: "mongodb://mongo:27017/reaction"
ports:
- "3000:3000"
- "9229:9229"
- "27017:27017"
volumes:
- .:/opt/reaction/src
- sshvolume:/opt/reaction/src
mongo:
image: mongo:3.4
command: mongod --storageEngine=wiredTiger
volumes:
- mongo-db:/data/db
volumes:
mongo-db:
sshvolume:
driver: "vieux/sshfs:latest"
driver_opts:
allow_other: ""
sshcmd: "<sshcmd>"
name: "sshvolume"
FROM ubuntu:16.04
ARG GIT_URL
RUN test -n "$GIT_URL"
RUN apt-get update
RUN apt-get install -y openssh-server
RUN apt-get install -y openssh-client
RUN apt-get install -y nano
RUN apt-get install -y mc
RUN apt-get install -y --no-install-recommends build-essential bzip2 curl ca-certificates git python
ENV NVM_DIR /usr/local/nvm
ENV NODE_VERSION 8.9.4
RUN curl https://install.meteor.com/ | sh
RUN curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bash
RUN . $NVM_DIR/nvm.sh \
&& nvm install $NODE_VERSION \
&& nvm alias default $NODE_VERSION \
&& nvm use default
ENV NODE_PATH $NVM_DIR/versions/node/v$NODE_VERSION/lib/node_modules
ENV PATH $NVM_DIR/versions/node/v$NODE_VERSION/bin:$PATH
RUN npm version
RUN node -v
RUN npm install -g reaction-cli
RUN mkdir -p /opt/reaction/src
WORKDIR /opt/reaction/src
COPY . .
RUN npm install -f
ENV ENV="/root/.bashrc"
RUN echo 'alias ll="ls -lthat"' >> /root/.bashrc
RUN echo 'export PS1="\[\e[0;32m\][PROJECT] \w\$\[\e[0m\] "' >> /root/.bashrc
#Change directory and clone git repo
RUN cd /opt/reaction/src \
&& git clone ${GIT_URL}
EXPOSE 3000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.