forked from asoul-sig/asouldocs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
214 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
.git | ||
.git/** | ||
custom* | ||
LICENSE | ||
Makefile | ||
.dockerignore | ||
*.yml | ||
*.md | ||
.bra.toml | ||
.gitignore | ||
Dockerfile* | ||
peach.sublime* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
FROM alpine:3.3 | ||
MAINTAINER [email protected] | ||
|
||
# Install system utils & runtime dependencies | ||
ADD https://github.com/tianon/gosu/releases/download/1.7/gosu-amd64 /usr/sbin/gosu | ||
RUN chmod +x /usr/sbin/gosu \ | ||
&& apk --no-cache --no-progress add ca-certificates bash git s6 curl socat | ||
|
||
COPY . /app/peach/ | ||
WORKDIR /app/peach/ | ||
RUN ./docker/build.sh | ||
|
||
# Configure LibC Name Service | ||
COPY docker/nsswitch.conf /etc/nsswitch.conf | ||
|
||
# Configure Docker Container | ||
VOLUME ["/data/peach"] | ||
EXPOSE 5555 | ||
ENTRYPOINT ["docker/start.sh"] | ||
CMD ["/bin/s6-svscan", "/app/peach/docker/s6/"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
# Docker for Peach | ||
|
||
Visit [Docker Hub](https://hub.docker.com/r/peachdocs/peach/) see all available tags. | ||
|
||
## Usage | ||
|
||
To keep your data out of Docker container, we do a volume (`/var/peach` -> `/data/peach`) here, and you can change it based on your situation. | ||
|
||
``` | ||
# Pull image from Docker Hub. | ||
$ docker pull peachdocs/peach | ||
# Create local directory for volume. | ||
$ mkdir -p /var/peach | ||
# Use `docker run` for the first time. | ||
# Peach will complain about missing custom app.ini, leave it there and see Settings section below. | ||
$ docker run --name=peach -p 5555:5555 -v /var/peach:/data/peach peachdocs/peach | ||
# Use `docker start` if you have stopped it. | ||
$ docker start peach | ||
``` | ||
|
||
Files will be store in local path `/var/peach` in my case. | ||
|
||
Directory `/var/peach` keeps Git repositories and Gogs data: | ||
|
||
/var/peach | ||
|-- custom | ||
|-- data | ||
|-- log | ||
|
||
### Volume with data container | ||
|
||
If you're more comfortable with mounting data to a data container, the commands you execute at the first time will look like as follows: | ||
|
||
``` | ||
# Create data container | ||
docker run --name=peach-data --entrypoint /bin/true peachdocs/peach | ||
# Use `docker run` for the first time. | ||
docker run --name=peach --volumes-from peach-data -p 5555:5555 peachdocs/peach | ||
``` | ||
|
||
#### Using Docker 1.9 Volume command | ||
|
||
``` | ||
# Create docker volume. | ||
$ docker volume create --name peach-data | ||
# Use `docker run` for the first time. | ||
$ docker run --name=peach -p 5555:5555 -v peach-data:/data/peach peachdocs/peach | ||
``` | ||
|
||
## Settings | ||
|
||
|
||
|
||
## Upgrade | ||
|
||
:exclamation::exclamation::exclamation:<span style="color: red">**Make sure you have volumed data to somewhere outside Docker container**</span>:exclamation::exclamation::exclamation: | ||
|
||
Steps to upgrade Peach with Docker: | ||
|
||
- `docker pull peachdocs/peach` | ||
- `docker stop peach` | ||
- `docker rm peach` | ||
- Finally, create container as the first time and don't forget to do same volume and port mapping. | ||
|
||
## Known Issues | ||
|
||
- The docker container can not currently be build on Raspberry 1 (armv6l) as our base image `alpine` does not have a `go` package available for this platform. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/bin/sh | ||
set -x | ||
set -e | ||
|
||
# Set temp environment vars | ||
export GOPATH=/tmp/go | ||
export PATH=${PATH}:${GOPATH}/bin | ||
|
||
# Install build deps | ||
apk --no-cache --no-progress add --virtual build-deps go gcc musl-dev | ||
|
||
# Init go environment to build | ||
mkdir -p ${GOPATH}/src/github.com/peachdocs/ | ||
ln -s /app/peach/ ${GOPATH}/src/github.com/peachdocs/peach | ||
cd ${GOPATH}/src/github.com/peachdocs/peach | ||
go get -v | ||
mv ${GOPATH}/bin/peach . | ||
|
||
# Cleanup GOPATH | ||
rm -r $GOPATH | ||
|
||
# Remove build deps | ||
apk --no-progress del build-deps | ||
|
||
# Create user | ||
adduser -H -D -g 'Peach Docs' peach -h /data/peach -s /bin/bash && passwd -u peach |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# /etc/nsswitch.conf | ||
|
||
passwd: compat | ||
group: compat | ||
shadow: compat | ||
|
||
hosts: files dns | ||
networks: files | ||
|
||
protocols: db files | ||
services: db files | ||
ethers: db files | ||
rpc: db files | ||
|
||
netgroup: nis |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/bin/sh | ||
|
||
# Cleanup SOCAT services and s6 event folder | ||
rm -rf $(find /app/peach/docker/s6/ -name 'event') | ||
rm -rf /app/peach/docker/s6/SOCAT_* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/bin/sh | ||
|
||
if test -f ./setup; then | ||
source ./setup | ||
fi | ||
|
||
exec gosu root /sbin/syslogd -nS -O- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#!/bin/sh | ||
|
||
create_socat_links() { | ||
# Bind linked docker container to localhost socket using socat | ||
USED_PORT="5555" | ||
while read NAME ADDR PORT; do | ||
if test -z "$NAME$ADDR$PORT"; then | ||
continue | ||
elif echo $USED_PORT | grep -E "(^|:)$PORT($|:)" > /dev/null; then | ||
echo "init:socat | Can't bind linked container ${NAME} to localhost, port ${PORT} already in use" 1>&2 | ||
else | ||
SERV_FOLDER=/app/gogs/docker/s6/SOCAT_${NAME}_${PORT} | ||
mkdir -p ${SERV_FOLDER} | ||
CMD="socat -ls TCP4-LISTEN:${PORT},fork,reuseaddr TCP4:${ADDR}:${PORT}" | ||
echo -e "#!/bin/sh\nexec $CMD" > ${SERV_FOLDER}/run | ||
chmod +x ${SERV_FOLDER}/run | ||
USED_PORT="${USED_PORT}:${PORT}" | ||
echo "init:socat | Linked container ${NAME} will be binded to localhost on port ${PORT}" 1>&2 | ||
fi | ||
done << EOT | ||
$(env | sed -En 's|(.*)_PORT_([0-9]+)_TCP=tcp://(.*):([0-9]+)|\1 \3 \4|p') | ||
EOT | ||
} | ||
|
||
cleanup() { | ||
# Cleanup SOCAT services and s6 event folder | ||
# On start and on shutdown in case container has been killed | ||
rm -rf $(find /app/peach/docker/s6/ -name 'event') | ||
rm -rf /app/peach/docker/s6/SOCAT_* | ||
} | ||
|
||
create_volume_subfolder() { | ||
# Create VOLUME subfolder | ||
for f in /data/peach/data /data/peach/custom /data/peach/log; do | ||
if ! test -d $f; then | ||
mkdir -p $f | ||
fi | ||
done | ||
} | ||
|
||
cleanup | ||
create_volume_subfolder | ||
|
||
LINK=$(echo "$SOCAT_LINK" | tr '[:upper:]' '[:lower:]') | ||
if [ "$LINK" = "false" -o "$LINK" = "0" ]; then | ||
echo "init:socat | Will not try to create socat links as requested" 1>&2 | ||
else | ||
create_socat_links | ||
fi | ||
|
||
# Exec CMD or S6 by default if nothing present | ||
if [ $# -gt 0 ];then | ||
exec "$@" | ||
else | ||
exec /bin/s6-svscan /app/peach/docker/s6/ | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters