Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bring image to a first working state #2

Merged
merged 9 commits into from
May 3, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.git
examples
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
examples/db
32 changes: 32 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
sudo: required
language: bash
services:
- docker

before_install:
- sudo apt-get -qq update
- sudo apt-get install -y openssl parallel


script:
# Initial build with default parameters
- docker build -t anope:testing .
# Run all tests from test directory
- ls tests/*.sh | parallel --joblog /tmp/joblog
- cat /tmp/joblog

after_success:
# Push successful builds of the master branch to Docker Hub
# You need to define $DOCKER_REPO_PREFIX, $DOCKER_REPO_NAME, $DOCKER_USERNAME and $DOCKER_PASSWORD in your Travis settings.
# $DOCKER_REPO_PREFIX - Organisation of username who owns the repo on Docker Hub
# $DOCKER_REPO_NAME - Repository name on Docker Hub
# $DOCKER_USERNAME - Docker Hub username used to push the image
# $DOCKER_PASSWORD - Password of the Docker Hub user used to push the image
# See https://docs.travis-ci.com/user/environment-variables/#Defining-Variables-in-Repository-Settings
- if [ "$TRAVIS_PULL_REQUEST" = "false" ] && [ "$TRAVIS_BRANCH" == "master" ] && [ "$DOCKER_REPO_PREFIX" != "" ] && [ "$DOCKER_REPO_NAME" != "" ] && [ "$DOCKER_USERNAME" != "" ] && [ "$DOCKER_PASSWORD" != "" ]; then
tools/tagging.sh "${DOCKER_REPO_PREFIX}/${DOCKER_REPO_NAME}" "${ANOPE_VERSION:-latest}" "";
docker images "${DOCKER_REPO_PREFIX}/${DOCKER_REPO_NAME}";
docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD";
docker images --format "{{.Repository}}:{{.Tag}}" "${DOCKER_REPO_PREFIX}/${DOCKER_REPO_NAME}" | xargs -L 1 docker push ;
docker run --rm -v "$(pwd)/:/data/:ro" -e "DOCKERHUB_USERNAME=$DOCKER_USERNAME" -e "DOCKERHUB_PASSWORD=$DOCKER_PASSWORD" -e "DOCKERHUB_REPO_PREFIX=$DOCKER_REPO_PREFIX" -e "DOCKERHUB_REPO_NAME=$DOCKER_REPO_NAME" sheogorath/readme-to-dockerhub;
fi
36 changes: 24 additions & 12 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,46 @@ MAINTAINER Adam [email protected]
MAINTAINER Sheogorath <[email protected]>

ARG VERSION=2.0
ARG ADDPACKAGES=
ARG DELPACKAGES=
ARG RUN_DEPENDENCIES=
ARG BUILD_DEPENDENCIES=

RUN apk add --no-cache gcc g++ make libgcc libstdc++ git cmake gnutls gnutls-dev gnutls-utils $ADDPACKAGES && \
RUN apk add --no-cache --virtual .build-utils gcc g++ make git cmake gnutls-dev sqlite-dev mariadb-dev $BUILD_DEPENDENCIES && \
apk add --no-cache --virtual .dependencies libgcc libstdc++ gnutls gnutls-utils sqlite-libs mariadb-client-libs $RUN_DEPENDENCIES && \
# Create a user to run anope later
adduser -u 10000 -h /anope/ -D -S anope && \
mkdir -p /src && \
cd /src && \
# Clone the requested version
git clone --depth 1 https://github.com/anope/anope.git anope -b $VERSION

RUN \
git clone --depth 1 https://github.com/anope/anope.git anope -b $VERSION && \
cd /src/anope && \
# Add and overwrite modules
ln -s /src/anope/modules/extra/m_ssl_gnutls.cpp modules && \
mkdir build && cd build && \
ln -s /src/anope/modules/extra/m_mysql.cpp modules && \
ln -s /src/anope/modules/extra/m_sqlite.cpp modules && \
mkdir build && \
cd /src/anope/build && \
cmake -DINSTDIR=/anope/ -DDEFUMASK=077 -DCMAKE_BUILD_TYPE=RELEASE .. && \
# Run build multi-threaded
make -j`getconf _NPROCESSORS_ONLN` install && \
# Uninstall all unnecessary tools after build process
apk del gcc g++ make git cmake gnutls-dev $DELPACKAGES && \
apk del .build-utils && \
rm -rf /src && \
# Keep example configs as good reference for users
# Make sure the application is allowed to write to it's own direcotry for
# logging and generation of certificates
chown -R anope /anope/
# Provide a data location
mkdir -p /data && \
touch /data/anope.db && \
ln -s /data/anope.db /anope/data/anope.db && \
# Make sure everything is owned by anope
chown -R anope /anope/ && \
chown -R anope /data/

COPY ./conf/ /anope/conf/

RUN chown -R anope /anope/conf/

WORKDIR /anope/

VOLUME /data/

USER anope

CMD ["/anope/bin/services", "-n"]
109 changes: 109 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
# Anope

Anope is a set of IRC Services designed for flexibility and ease of use.

Anope is a set of Services for IRC networks that allows users to manage their nicks and channels in a secure and efficient way, and administrators to manage their network with powerful tools.


# How to use this image

This image is not usable as stand alone image. You need some kind of IRCd.

For example you can use [InspIRCd](https://hub.docker.com/r/inspircd/inspircd-docker) like in the [example](https://github.com/Adam-/anope-docker/blob/master/examples/docker-compose.yml).

The minimal configuration looks like this:

```console
$ docker run --name anope -e "ANOPE_UPLINK_IP=irc.example.org" -e "ANOPE_UPLINK_PASSWORD=password" anope/anope
```

You can use your own configs in this container by mounting them to `/anope/conf/`:

```console
$ docker run --name anope -v /path/to/your/config:/anope/conf/ anope/anope
```


## Generated configuration

This image provides various options to configure it by environment variables.

Use the following environment variables to configure your container:

|Available variables |Default value |Description |
|-------------------------|--------------------------------|--------------------------------------------|
|`ANOPE_SERVICES_NAME` |`services.localhost.net` |Name of the services. *Important for uplink*|
|`ANOPE_SERVICES_VHOST` |`services.localhost.net` |Host used by services pseudo clients |
|`ANOPE_UPLINK_IP` |no default |DNS name or IP of the uplink host |
|`ANOPE_UPLINK_PORT` |`7000` |Port used to connect to uplink host |
|`ANOPE_UPLINK_PASSWORD` |no default |Password used to authenticate against uplink|


## Database configuration

This image provides two way to configure database handling. You can use sqlite inside a volume or an external mysqldb.

SQLite is used by default to prevent failing of the container, but mysql is recommended.


### SQLite

For very small setup, development and testing SQLite setup should be enough. Simply make sure you mount a volume to `/data`.

```console
$ docker run --name anope -v "/path/to/datastore:/data" -e "ANOPE_UPLINK_IP=irc.example.org" -e "ANOPE_UPLINK_PASSWORD=password" anope/anope
```

### MySQL

For a production setup MySQL is the recommended way to set this image up. Checkout the [example](https://github.com/Adam-/anope-docker/blob/master/examples/docker-compose.yml) if you want to test it.

|Available variables |Default value |Description |
|-------------------------|--------------------------------|--------------------------------------------|
|`ANOPE_SQL_ENGINE` |`sqlite` |Set it to `mysql` to enable `mysql` backend |
|`ANOPE_MYSQL_DB` |`anope` |Database name for the data |
|`ANOPE_MYSQL_HOST` |`database` |Hostname of the database host or container |
|`ANOPE_MYSQL_PORT` |`3306` |Port used to access the mysql database |
|`ANOPE_MYSQL_USER` |`anope` |Username for the MySQL database |
|`ANOPE_MYSQL_PASSWORD` |no default |Password for the `ANOPE_MYSQL_USER` |
|`ANOPE_SQL_LIVE` |`no` |Enable Anope SQL-DB live feature |


# Updates and updating

To update your setup simply pull the newest image version from docker hub and run it.

```console
$ docker pull anope/anope
```

Considering to update your docker setup regularly.


# License

View [license information](https://github.com/anope/anope) for the software contained in this image.


# Supported Docker versions

This image is officially supported on Docker version 17.03.1-CE.

Support for older versions (down to 1.12) is provided on a best-effort basis.

Please see [the Docker installation documentation](https://docs.docker.com/installation/) for details on how to upgrade your Docker daemon.


# User Feedback

## Issues

If you have any problems with or questions about this image, please contact us through a [GitHub issue](https://github.com/Adam-/anope-docker/issues).

You can also reach many of the project maintainers via the `#anope` IRC channel on [Teranova](http://www.teranova.net/).


## Contributing

You are invited to contribute new features, fixes, or updates, large or small; we are always thrilled to receive pull requests, and do our best to process them as fast as we can.

15 changes: 15 additions & 0 deletions conf/config.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/sh

cat <<EOF
define
{
name = "services.host"
value = "${ANOPE_SERVICES_VHOST:-services.localhost.net}"
}

define
{
name = "services.name"
value = "${ANOPE_SERVICES_NAME:-services.localhost.net}"
}
EOF
104 changes: 104 additions & 0 deletions conf/database.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
#!/bin/sh

if [ "$ANOPE_SQL_LIVE" = "yes" ]; then
ANOPE_SQL_LIVE="_live"
else
ANOPE_SQL_LIVE=""
fi

cat <<EOF

/*
* db_sql and db_sql_live
*
* db_sql module allows saving and loading databases using one of the SQL engines.
* This module loads the databases once on startup, then incrementally updates
* objects in the database as they are changed within Anope in real time. Changes
* to the SQL tables not done by Anope will have no effect and will be overwritten.
*
* db_sql_live module allows saving and loading databases using one of the SQL engines.
* This module reads and writes to SQL in real time. Changes to the SQL tables
* will be immediately reflected into Anope. This module should not be loaded
* in conjunction with db_sql.
*
*/
module
{
name = "db_sql${ANOPE_SQL_LIVE}"

/*
* The SQL service db_sql(_live) should use, these are configured in modules.conf.
* For MySQL, this should probably be mysql/main.
*/
engine = "${ANOPE_SQL_ENGINE:-sqlite}/main"

/*
* An optional prefix to prepended to the name of each created table.
* Do not use the same prefix for other programs.
*/
#prefix = "anope_db_"

/* Whether or not to import data from another database module in to SQL on startup.
* If you enable this, be sure that the database services is configured to use is
* empty and that another database module to import from is loaded before db_sql.
* After you enable this and do a database import you should disable it for
* subsequent restarts.
*
* Note that you can not import databases using db_sql_live. If you want to import
* databases and use db_sql_live you should import them using db_sql, then shut down
* and start services with db_sql_live.
*/
import = false
}
EOF

if [ "$ANOPE_SQL_ENGINE" = "mysql" ]; then

cat <<EOF
/*
* m_mysql [EXTRA]
*
* This module allows other modules to use MySQL.
*/
module
{
name = "m_mysql"

mysql
{
/* The name of this service. */
name = "mysql/main"
database = "${ANOPE_MYSQL_DB:-anope}"
server = "${ANOPE_MYSQL_HOST:-database}"
port = ${ANOPE_MYSQL_PORT:-3306}
username = "${ANOPE_MYSQL_USER:-anope}"
password = "$ANOPE_MYSQL_PASSWORD"
}
}
EOF

# Use SQLite as default
else

cat <<EOF
/*
* m_sqlite [EXTRA]
*
* This module allows other modules to use SQLite.
*/
module
{
name = "m_sqlite"

/* A SQLite database */
sqlite
{
/* The name of this service. */
name = "sqlite/main"

/* The database name, it will be created if it does not exist. */
database = "anope.db"
}
}
EOF
fi
50 changes: 50 additions & 0 deletions conf/serverinfo.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* [REQUIRED] Server Information
*
* This section contains information about the Services server.
*/
serverinfo
{
/*
* The hostname that Services will be seen as, it must have no conflicts with any
* other server names on the rest of your IRC network. Note that it does not have
* to be an existing hostname, just one that isn't on your network already.
*/
name = "services.name"

/*
* The text which should appear as the server's information in /whois and similar
* queries.
*/
description = "Services for IRC Networks"

/*
* The local address that Services will bind to before connecting to the remote
* server. This may be useful for multihomed hosts. If omitted, Services will let
* the Operating System choose the local address. This directive is optional.
*
* If you don't know what this means or don't need to use it, just leave this
* directive commented out.
*/
#localhost = "nowhere."

/*
* What Server ID to use for this connection?
* Note: This should *ONLY* be used for TS6/P10 IRCds. Refer to your IRCd documentation
* to see if this is needed.
*/
#id = "00A"

/*
* The filename containing the Services process ID. The path is relative to the
* services root directory.
*/
pid = "/tmp/services.pid"

/*
* The filename containing the Message of the Day. The path is relative to the
* services root directory.
*/
motd = "conf/services.motd"
}

Loading