mirror of https://github.com/gogits/gogs.git
无闻
11 years ago
6 changed files with 119 additions and 47 deletions
@ -1,25 +1,29 @@ |
|||||||
# Configs of the docker images, you might have specify your own configs here. |
# Configs of the docker images, you might have specify your own configs here. |
||||||
MYSQL_PASSWORD="YOUR_MYSQL_PASSWORD" |
# type of database, support 'mysql' and 'postgres' |
||||||
MYSQL_RUN_NAME="YOUR_MYSQL_RUN_NAME" |
DB_TYPE="postgres" |
||||||
|
DB_PASSWORD="YOUR_DB_PASSWORD" |
||||||
|
DB_RUN_NAME="YOUR_DB_RUN_NAME" |
||||||
HOST_PORT="YOUR_HOST_PORT" |
HOST_PORT="YOUR_HOST_PORT" |
||||||
|
|
||||||
# Replace the mysql root password in MySQL image Dockerfile. |
# Replace the database root password in database image Dockerfile. |
||||||
sed -i "s/THE_MYSQL_PASSWORD/$MYSQL_PASSWORD/g" images/mysql/Dockerfile |
sed -i "s/THE_DB_PASSWORD/$DB_PASSWORD/g" images/$DB_TYPE/Dockerfile |
||||||
# Replace the mysql root password in gogits image Dockerfile. |
# Replace the database root password in gogits image deploy.sh file. |
||||||
sed -i "s/THE_MYSQL_PASSWORD/$MYSQL_PASSWORD/g" images/gogits/deploy.sh |
sed -i "s/THE_DB_PASSWORD/$DB_PASSWORD/g" images/gogits/deploy.sh |
||||||
|
# Replace the database type in gogits image deploy.sh file. |
||||||
|
sed -i "s/THE_DB_TYPE/$DB_TYPE/g" images/gogits/deploy.sh |
||||||
|
|
||||||
# Build the MySQL image |
# Build the database image |
||||||
cd images/mysql |
cd images/$DB_TYPE |
||||||
docker build -t gogs/mysql . |
docker build -t gogs/$DB_TYPE . |
||||||
# |
# |
||||||
## Build the gogits image |
## Build the gogits image |
||||||
cd ../gogits |
cd ../gogits |
||||||
docker build -t gogs/gogits . |
docker build -t gogs/gogits . |
||||||
# |
# |
||||||
## Run MySQL image with name |
## Run MySQL image with name |
||||||
docker run -d --name $MYSQL_RUN_NAME gogs/mysql |
docker run -d --name $DB_RUN_NAME gogs/$DB_TYPE |
||||||
# |
# |
||||||
## Run gogits image and link it to the MySQL image |
## Run gogits image and link it to the database image |
||||||
echo "Now we have the MySQL image(running) and gogs image, use the follow command to start gogs service:" |
echo "Now we have the $DB_TYPE image(running) and gogs image, use the follow command to start gogs service:" |
||||||
echo -e "\033[33m docker run -i -t --link $MYSQL_RUN_NAME:db -p $HOST_PORT:3000 gogs/gogits \033[0m" |
echo -e "\033[33m docker run -i -t --link $DB_RUN_NAME:db -p $HOST_PORT:3000 gogs/gogits \033[0m" |
||||||
|
|
||||||
|
@ -1,27 +1,29 @@ |
|||||||
# Configs |
# Configs of the docker images, you might have specify your own configs here. |
||||||
MYSQL_PASSWORD="YOUR_MYSQL_PASSWORD" |
# type of database, support 'mysql' and 'postgres' |
||||||
MYSQL_RUN_NAME="YOUR_MYSQL_RUN_NAME" |
DB_TYPE="postgres" |
||||||
typeset -u MYSQL_ALIAS |
DB_PASSWORD="YOUR_DB_PASSWORD" |
||||||
MYSQL_ALIAS="YOUR_MYSQL_ALIAS" |
DB_RUN_NAME="YOUR_DB_RUN_NAME" |
||||||
HOST_PORT="YOUR_HOST_PORT" |
HOST_PORT="YOUR_HOST_PORT" |
||||||
|
|
||||||
# Replace the mysql root password in MySQL image Dockerfile. |
# Replace the database root password in database image Dockerfile. |
||||||
sed -i "s/THE_MYSQL_PASSWORD/$MYSQL_PASSWORD/g" images/mysql/Dockerfile |
sed -i "s/THE_DB_PASSWORD/$DB_PASSWORD/g" images/$DB_TYPE/Dockerfile |
||||||
# Replace the mysql root password in gogits image Dockerfile. |
# Replace the database root password in gogits image deploy.sh file. |
||||||
sed -i "s/THE_MYSQL_PASSWORD/$MYSQL_PASSWORD/g" images/gogits/Dockerfile |
sed -i "s/THE_DB_PASSWORD/$DB_PASSWORD/g" images/gogits/deploy.sh |
||||||
|
# Replace the database type in gogits image deploy.sh file. |
||||||
|
sed -i "s/THE_DB_TYPE/$DB_TYPE/g" images/gogits/deploy.sh |
||||||
|
|
||||||
|
# Build the database image |
||||||
# Build the MySQL image |
cd images/$DB_TYPE |
||||||
cd images/mysql |
docker build -t gogs/$DB_TYPE . |
||||||
docker build -i gogs/mysql . |
# |
||||||
|
## Build the gogits image |
||||||
# Build the gogits image |
cd ../gogits |
||||||
cd images/gogits |
docker build -t gogs/gogits . |
||||||
docker build -i gogs/gogits . |
# |
||||||
|
## Run MySQL image with name |
||||||
# Run MySQL image with name |
docker run -d --name $DB_RUN_NAME gogs/$DB_TYPE |
||||||
docker run -d --name $MYSQL_RUN_NAME gogs/mysql |
# |
||||||
|
## Run gogits image and link it to the database image |
||||||
# Run gogits image and link it to the MySQL image |
echo "Now we have the $DB_TYPE image(running) and gogs image, use the follow command to start gogs service:" |
||||||
docker run --link $MYSQL_RUN_NAME:$MYSQL_ALIAS -p $HOST_PORT:3000 gogs/gogits |
echo -e "\033[33m docker run -i -t --link $DB_RUN_NAME:db -p $HOST_PORT:3000 gogs/gogits \033[0m" |
||||||
|
|
||||||
|
@ -0,0 +1,49 @@ |
|||||||
|
FROM ubuntu |
||||||
|
MAINTAINER SvenDowideit@docker.com |
||||||
|
|
||||||
|
# Add the PostgreSQL PGP key to verify their Debian packages. |
||||||
|
# It should be the same key as https://www.postgresql.org/media/keys/ACCC4CF8.asc |
||||||
|
RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys B97B0AFCAA1A47F044F244A07FCC7D46ACCC4CF8 |
||||||
|
|
||||||
|
# Add PostgreSQL's repository. It contains the most recent stable release |
||||||
|
# of PostgreSQL, ``9.3``. |
||||||
|
RUN echo "deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main" > /etc/apt/sources.list.d/pgdg.list |
||||||
|
|
||||||
|
# Update the Ubuntu and PostgreSQL repository indexes |
||||||
|
RUN apt-get update |
||||||
|
|
||||||
|
# Install ``python-software-properties``, ``software-properties-common`` and PostgreSQL 9.3 |
||||||
|
# There are some warnings (in red) that show up during the build. You can hide |
||||||
|
# them by prefixing each apt-get statement with DEBIAN_FRONTEND=noninteractive |
||||||
|
RUN apt-get -y -q install python-software-properties software-properties-common |
||||||
|
RUN apt-get -y -q install postgresql-9.3 postgresql-client-9.3 postgresql-contrib-9.3 |
||||||
|
|
||||||
|
# Note: The official Debian and Ubuntu images automatically ``apt-get clean`` |
||||||
|
# after each ``apt-get`` |
||||||
|
|
||||||
|
# Run the rest of the commands as the ``postgres`` user created by the ``postgres-9.3`` package when it was ``apt-get installed`` |
||||||
|
USER postgres |
||||||
|
|
||||||
|
# Create a PostgreSQL role named ``docker`` with ``docker`` as the password and |
||||||
|
# then create a database `docker` owned by the ``docker`` role. |
||||||
|
# Note: here we use ``&&\`` to run commands one after the other - the ``\`` |
||||||
|
# allows the RUN command to span multiple lines. |
||||||
|
RUN /etc/init.d/postgresql start &&\ |
||||||
|
psql --command "CREATE USER root WITH SUPERUSER PASSWORD 'THE_DB_PASSWORD';" &&\ |
||||||
|
createdb -O root gogs |
||||||
|
|
||||||
|
# Adjust PostgreSQL configuration so that remote connections to the |
||||||
|
# database are possible. |
||||||
|
RUN echo "host all all 0.0.0.0/0 md5" >> /etc/postgresql/9.3/main/pg_hba.conf |
||||||
|
|
||||||
|
# And add ``listen_addresses`` to ``/etc/postgresql/9.3/main/postgresql.conf`` |
||||||
|
RUN echo "listen_addresses='*'" >> /etc/postgresql/9.3/main/postgresql.conf |
||||||
|
|
||||||
|
# Expose the PostgreSQL port |
||||||
|
EXPOSE 5432 |
||||||
|
|
||||||
|
# Add VOLUMEs to allow backup of config, logs and databases |
||||||
|
VOLUME ["/etc/postgresql", "/var/log/postgresql", "/var/lib/postgresql"] |
||||||
|
|
||||||
|
# Set the default command to run when starting the container |
||||||
|
CMD ["/usr/lib/postgresql/9.3/bin/postgres", "-D", "/var/lib/postgresql/9.3/main", "-c", "config_file=/etc/postgresql/9.3/main/postgresql.conf"] |
Loading…
Reference in new issue