Play Raspberry Pi Nginx Docker

Play Raspberry Pi Nginx Docker

The project will be named as raspberrypi-nginx

normal Makefile as follow
IMAGE=sillycat/public
TAG=raspberrypi-nginx
NAME=raspberrypi-nginx

prepare:
wget http://nginx.org/download/nginx-1.11.6.tar.gz -P install/

docker-context:

build: docker-context
docker build -t $(IMAGE):$(TAG) .

run:
docker run -d -p 80:80 -v /opt/disk1/nas_cloud/sillycat/person:/data/sillycat -v /opt/disk1/nas_cloud/sillycat/share:/data/share --name $(NAME) $(IMAGE):$(TAG)

debug:
docker run -ti -p 80:80 -v /opt/disk1/nas_cloud/sillycat/person:/data/sillycat -v /opt/disk1/nas_cloud/sillycat/share:/data/share --name $(NAME) $(IMAGE):$(TAG) /bin/bash

clean:
docker stop ${NAME}
docker rm ${NAME}

logs:
docker logs ${NAME}

publish:
docker push ${IMAGE}:${TAG}

fetch:
docker pull ${IMAGE}:${TAG}


The Dockerfile will show how I install the nginx software on ubuntu initial image, I am using 1.11.6 version which is the latest currently.

#Set up nginx in Docker

#Prepre the OS
FROM resin/rpi-raspbian:jessie
MAINTAINER Carl Luo <[email protected]>

ENV DEBIAN_FRONTEND noninteractive
RUN apt-get -y update
RUN apt-get install -y apt-utils
RUN apt-get -y dist-upgrade
RUN apt-get install -y build-essential gcc make
RUN apt-get install -y libpcre3 libpcre3-dev zlib1g-dev libgcrypt11-dev

#install nginx
RUN     mkdir -p /tool
RUN     mkdir -p /install
ADD install/nginx-1.11.6.tar.gz /install/
WORKDIR /install/nginx-1.11.6
RUN ./configure --prefix=/tool/nginx-1.11.6
RUN     make
RUN     make install

#config nginx
ADD     conf/nginx.conf /tool/nginx-1.11.6/conf/

#start the application
EXPOSE  80
RUN     mkdir -p /app/
ADD     start.sh /app/
WORKDIR /app/
CMD [ "./start.sh" ]

The script file start.sh to start the nginx service and keep it running in the back
#!/bin/sh -ex

#start the nginx
cd /tool/nginx-1.11.6
sbin/nginx -g "daemon off;"

Since I do not set up static html/js projects yet, so I just run this nginx project alone with default conf/nginx.conf

>make prepare
>make build
>make run

Visit the page http://localhost will work.

References:
http://sillycat.iteye.com/blog/2166582

猜你喜欢

转载自sillycat.iteye.com/blog/2342179