Skip to content

Commit 86aa8e4

Browse files
author
Thomas Boerger
committed
Restructured docker building
I have restructured the docker build process entirely, the binary gets built outside of the docker build command, now we are managing all dependencies with real Alpine packages and I have dropped features like socat or the cron daemon. Signed-off-by: Thomas Boerger <[email protected]>
1 parent bf8d90c commit 86aa8e4

File tree

29 files changed

+223
-356
lines changed

29 files changed

+223
-356
lines changed

.dockerignore

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,5 @@
1-
.git
2-
.git/**
3-
packager
4-
packager/**
5-
scripts
6-
scripts/**
7-
.github/
8-
.github/**
9-
config.codekit
10-
.dockerignore
11-
*.yml
12-
*.md
13-
.bra.toml
14-
.editorconfig
15-
.gitignore
16-
Dockerfile*
17-
vendor
18-
vendor/**
19-
gogs
1+
*
2+
!docker
3+
!bin
4+
!public
5+
!templates

Dockerfile

Lines changed: 42 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,47 @@
1-
FROM alpine:3.3
2-
1+
FROM alpine:edge
2+
MAINTAINER Thomas Boerger <[email protected]>
33

4-
# Install system utils & Gogs runtime dependencies
5-
ADD https://github.com/tianon/gosu/releases/download/1.9/gosu-amd64 /usr/sbin/gosu
6-
RUN chmod +x /usr/sbin/gosu \
7-
&& apk --no-cache --no-progress add ca-certificates bash git linux-pam s6 curl openssh socat tzdata
8-
9-
ENV GITEA_CUSTOM /data/gogs
4+
EXPOSE 22 3000
105

11-
COPY . /app/gogs/
12-
WORKDIR /app/gogs/
13-
RUN ./docker/build.sh
6+
RUN echo "@testing http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories && \
7+
apk -U add \
8+
gosu@testing \
9+
shadow \
10+
ca-certificates \
11+
sqlite \
12+
bash \
13+
git \
14+
linux-pam \
15+
s6 \
16+
curl \
17+
openssh \
18+
tzdata && \
19+
rm -rf \
20+
/var/cache/apk/* && \
21+
groupadd \
22+
-r \
23+
-g 1000 \
24+
git && \
25+
useradd \
26+
-r -M \
27+
-p '*' \
28+
-d /data/git \
29+
-s /bin/bash \
30+
-u 1000 \
31+
-g git \
32+
git
1433

15-
# Configure LibC Name Service
16-
COPY docker/nsswitch.conf /etc/nsswitch.conf
34+
ENV USER git
35+
ENV GITEA_CUSTOM /data/gitea
36+
ENV GODEBUG=netdns=go
1737

18-
# Configure Docker Container
1938
VOLUME ["/data"]
20-
EXPOSE 22 3000
21-
ENTRYPOINT ["docker/start.sh"]
22-
CMD ["/bin/s6-svscan", "/app/gogs/docker/s6/"]
39+
40+
ENTRYPOINT ["/usr/bin/entrypoint"]
41+
CMD ["/bin/s6-svscan", "/etc/s6"]
42+
43+
COPY docker /
44+
45+
COPY public /app/gitea/public
46+
COPY templates /app/gitea/templates
47+
COPY bin/gitea /app/gitea/gitea

Dockerfile.rpi

Lines changed: 42 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,47 @@
1-
FROM hypriot/rpi-alpine-scratch:v3.2
2-
1+
FROM hypriot/rpi-alpine-scratch:edge
2+
MAINTAINER Thomas Boerger <[email protected]>
33

4-
# Install system utils & Gogs runtime dependencies
5-
ADD https://github.com/tianon/gosu/releases/download/1.9/gosu-armhf /usr/sbin/gosu
6-
RUN chmod +x /usr/sbin/gosu \
7-
&& echo "http://dl-4.alpinelinux.org/alpine/v3.3/main/" | tee /etc/apk/repositories \
8-
&& echo "http://dl-4.alpinelinux.org/alpine/v3.3/community/" | tee -a /etc/apk/repositories \
9-
&& apk -U --no-progress upgrade && rm -f /var/cache/apk/APKINDEX.* \
10-
&& apk --no-cache --no-progress add ca-certificates bash git linux-pam s6 curl openssh socat tzdata
11-
12-
ENV GITEA_CUSTOM /data/gogs
4+
EXPOSE 22 3000
135

14-
COPY . /app/gogs/
15-
WORKDIR /app/gogs/
16-
RUN ./docker/build.sh
6+
RUN echo "@testing http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories && \
7+
apk -U add \
8+
gosu@testing \
9+
shadow \
10+
ca-certificates \
11+
sqlite \
12+
bash \
13+
git \
14+
linux-pam \
15+
s6 \
16+
curl \
17+
openssh \
18+
tzdata && \
19+
rm -rf \
20+
/var/cache/apk/* && \
21+
groupadd \
22+
-r \
23+
-g 1000 \
24+
git && \
25+
useradd \
26+
-r -M \
27+
-p '*' \
28+
-d /data/git \
29+
-s /bin/bash \
30+
-u 1000 \
31+
-g git \
32+
git
1733

18-
# Configure LibC Name Service
19-
COPY docker/nsswitch.conf /etc/nsswitch.conf
34+
ENV USER git
35+
ENV GITEA_CUSTOM /data/gitea
36+
ENV GODEBUG=netdns=go
2037

21-
# Configure Docker Container
2238
VOLUME ["/data"]
23-
EXPOSE 22 3000
24-
ENTRYPOINT ["docker/start.sh"]
25-
CMD ["/bin/s6-svscan", "/app/gogs/docker/s6/"]
39+
40+
ENTRYPOINT ["/usr/bin/entrypoint"]
41+
CMD ["/bin/s6-svscan", "/etc/s6"]
42+
43+
COPY docker /
44+
45+
COPY public /app/gitea/public
46+
COPY templates /app/gitea/templates
47+
COPY bin/gitea /app/gitea/gitea

docker/README.md

Lines changed: 0 additions & 111 deletions
This file was deleted.

docker/build.sh

Lines changed: 0 additions & 36 deletions
This file was deleted.

docker/nsswitch.conf renamed to docker/etc/nsswitch.conf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,3 @@ ethers: db files
1313
rpc: db files
1414

1515
netgroup: nis
16-

docker/etc/profile.d/gitea.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/bash
2+
export GITEA_CUSTOM=/data/gitea

docker/etc/s6/.s6-svscan/finish

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/bash
2+
exit 0

docker/etc/s6/gitea/finish

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/bash
2+
exit 0

docker/etc/s6/gitea/run

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
[[ -f ./setup ]] && source ./setup
3+
4+
pushd /app/gitea > /dev/null
5+
exec gosu git /app/gitea/gitea web
6+
popd

docker/etc/s6/gitea/setup

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash
2+
3+
if [ ! -d /data/git/.ssh ]; then
4+
mkdir -p /data/git/.ssh
5+
chmod 700 /data/git/.ssh
6+
fi
7+
8+
if [ ! -f /data/git/.ssh/environment ]; then
9+
echo "GITEA_CUSTOM=/data/gitea" >| /data/git/.ssh/environment
10+
chmod 600 /data/git/.ssh/environment
11+
fi
12+
13+
if [ ! -f /data/gitea/conf/app.ini ]; then
14+
mkdir -p /data/gitea/conf
15+
cp /etc/templates/app.ini /data/gitea/conf/app.ini
16+
fi
17+
18+
chown -R git:git /data/gitea /app/gitea /data/git
19+
chmod 0755 /data/gitea /app/gitea /data/git

docker/etc/s6/openssh/finish

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/bash
2+
exit 0

docker/etc/s6/openssh/run

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
[[ -f ./setup ]] && source ./setup
3+
4+
pushd /root > /dev/null
5+
exec gosu root /usr/sbin/sshd -E /var/log/sshd.log -D
6+
popd

docker/etc/s6/openssh/setup

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/bin/bash
2+
3+
if [ ! -d /data/ssh ]; then
4+
mkdir -p /data/ssh
5+
fi
6+
7+
if [ ! -f /data/ssh/ssh_host_ed25519_key ]; then
8+
echo "Generating /data/ssh/ssh_host_ed25519_key..."
9+
ssh-keygen -t ed25519 -b 4096 -f /data/ssh/ssh_host_ed25519_key -N "" > /dev/null
10+
fi
11+
12+
if [ ! -f /data/ssh/ssh_host_rsa_key ]; then
13+
echo "Generating /data/ssh/ssh_host_rsa_key..."
14+
ssh-keygen -t rsa -b 2048 -f /data/ssh/ssh_host_rsa_key -N "" > /dev/null
15+
fi
16+
17+
if [ ! -f /data/ssh/ssh_host_dsa_key ]; then
18+
echo "Generating /data/ssh/ssh_host_dsa_key..."
19+
ssh-keygen -t dsa -f /data/ssh/ssh_host_dsa_key -N "" > /dev/null
20+
fi
21+
22+
if [ ! -f /data/ssh/ssh_host_ecdsa_key ]; then
23+
echo "Generating /data/ssh/ssh_host_ecdsa_key..."
24+
ssh-keygen -t ecdsa -b 256 -f /data/ssh/ssh_host_ecdsa_key -N "" > /dev/null
25+
fi
26+
27+
chown root:root /data/ssh/*
28+
chmod 0700 /data/ssh
29+
chmod 0600 /data/ssh/*

docker/etc/s6/syslogd/finish

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/bash
2+
exit 0

docker/etc/s6/syslogd/run

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
[[ -f ./setup ]] && source ./setup
3+
4+
pushd /root > /dev/null
5+
exec gosu root /sbin/syslogd -nS -O-
6+
popd

docker/etc/s6/syslogd/setup

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#!/bin/bash

0 commit comments

Comments
 (0)