Skip to content

Commit

Permalink
cleanup build
Browse files Browse the repository at this point in the history
  • Loading branch information
mrhotio committed Aug 25, 2023
1 parent 15a8ac4 commit 2b48124
Show file tree
Hide file tree
Showing 25 changed files with 34 additions and 229 deletions.
23 changes: 5 additions & 18 deletions linux-amd64.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,17 @@ ARG UPSTREAM_DIGEST_AMD64
FROM golang:alpine as builder
ARG VERSION
RUN apk add --no-cache curl jq
RUN mkdir /caddy && \
xcaddy_version=$(curl -u "${GITHUB_ACTOR}:${GITHUB_TOKEN}" -fsSL "https://api.github.com/repos/caddyserver/xcaddy/releases/latest" | jq -r .tag_name | sed s/v//g) && \
wget -O - "https://github.com/caddyserver/xcaddy/releases/download/v${xcaddy_version}/xcaddy_${xcaddy_version}_linux_arm64.tar.gz" | tar xzf - -C "/bin" && \
cd /caddy && \
xcaddy build v${VERSION} --output /caddy/caddy \
RUN xcaddy_version=$(curl -u "${GITHUB_ACTOR}:${GITHUB_TOKEN}" -fsSL "https://api.github.com/repos/caddyserver/xcaddy/releases/latest" | jq -r .tag_name | sed s/v//g) && \
wget -O - "https://github.com/caddyserver/xcaddy/releases/download/v${xcaddy_version}/xcaddy_${xcaddy_version}_linux_amd64.tar.gz" | tar xzf - -C "/bin" && \
xcaddy build v${VERSION} --output /caddy-bin \
--with github.com/caddy-dns/cloudflare && \
chmod 755 "/caddy/caddy"
chmod 755 "/caddy-bin"


FROM ${UPSTREAM_IMAGE}@${UPSTREAM_DIGEST_AMD64}
EXPOSE 8080 8443
VOLUME ["${CONFIG_DIR}"]

ENV CUSTOM_BUILD=""

RUN apk add --no-cache nss-tools fail2ban cronie logrotate

ARG VERSION
COPY --from=builder /caddy/caddy "${APP_DIR}/caddy"
RUN chmod -R u=rwX,go=rX "${APP_DIR}" && \
ln -s "${APP_DIR}/caddy" "/usr/local/bin/caddy" && \
cp -R /etc/fail2ban "${APP_DIR}/" && \
rm -rf /etc/fail2ban && \
ln -s "${CONFIG_DIR}/fail2ban" "/etc/fail2ban"

COPY --from=builder /caddy-bin "${APP_DIR}/caddy"
COPY root/ /
RUN chmod -R +x /etc/cont-init.d/ /etc/services.d/
21 changes: 4 additions & 17 deletions linux-arm64.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,17 @@ ARG UPSTREAM_DIGEST_ARM64
FROM golang:alpine as builder
ARG VERSION
RUN apk add --no-cache curl jq
RUN mkdir /caddy && \
xcaddy_version=$(curl -u "${GITHUB_ACTOR}:${GITHUB_TOKEN}" -fsSL "https://api.github.com/repos/caddyserver/xcaddy/releases/latest" | jq -r .tag_name | sed s/v//g) && \
RUN xcaddy_version=$(curl -u "${GITHUB_ACTOR}:${GITHUB_TOKEN}" -fsSL "https://api.github.com/repos/caddyserver/xcaddy/releases/latest" | jq -r .tag_name | sed s/v//g) && \
wget -O - "https://github.com/caddyserver/xcaddy/releases/download/v${xcaddy_version}/xcaddy_${xcaddy_version}_linux_arm64.tar.gz" | tar xzf - -C "/bin" && \
cd /caddy && \
xcaddy build v${VERSION} --output /caddy/caddy \
xcaddy build v${VERSION} --output /caddy-bin \
--with github.com/caddy-dns/cloudflare && \
chmod 755 "/caddy/caddy"
chmod 755 "/caddy-bin"


FROM ${UPSTREAM_IMAGE}@${UPSTREAM_DIGEST_ARM64}
EXPOSE 8080 8443
VOLUME ["${CONFIG_DIR}"]

ENV CUSTOM_BUILD=""

RUN apk add --no-cache nss-tools fail2ban cronie logrotate

ARG VERSION
COPY --from=builder /caddy/caddy "${APP_DIR}/caddy"
RUN chmod -R u=rwX,go=rX "${APP_DIR}" && \
ln -s "${APP_DIR}/caddy" "/usr/local/bin/caddy" && \
cp -R /etc/fail2ban "${APP_DIR}/" && \
rm -rf /etc/fail2ban && \
ln -s "${CONFIG_DIR}/fail2ban" "/etc/fail2ban"

COPY --from=builder /caddy-bin "${APP_DIR}/caddy"
COPY root/ /
RUN chmod -R +x /etc/cont-init.d/ /etc/services.d/
25 changes: 24 additions & 1 deletion root/app/Caddyfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,34 @@
abort @block
}

:8080 {
(security_headers) {
header {
Strict-Transport-Security "max-age=31536000; includeSubDomains;"
X-Frame-Options "SAMEORIGIN"
X-Content-Type-Options "nosniff"
Referrer-Policy "strict-origin"
X-Robots-Tag "noindex, nofollow, nosnippet, noarchive"
}
}

(log_settings) {
log {
output file /config/logs/access.log
level WARN
}
}

# Default http file server
:8080 {
import log_settings
root * /app/www
file_server
import block_world
}

# Default reverse proxy template for your domain
# sub.yourdomain.com {
# import log_settings
# import security_headers
# reverse_proxy server:8080
# }
2 changes: 0 additions & 2 deletions root/app/crontab/default

This file was deleted.

3 changes: 0 additions & 3 deletions root/app/fail2ban/fail2ban.d/custom_settings.local

This file was deleted.

3 changes: 0 additions & 3 deletions root/app/fail2ban/filter.d/caddy-4xx.local

This file was deleted.

3 changes: 0 additions & 3 deletions root/app/fail2ban/filter.d/jellyfin.local

This file was deleted.

3 changes: 0 additions & 3 deletions root/app/fail2ban/filter.d/jellyseerr.local

This file was deleted.

3 changes: 0 additions & 3 deletions root/app/fail2ban/filter.d/overseerr.local

This file was deleted.

3 changes: 0 additions & 3 deletions root/app/fail2ban/filter.d/petio.local

This file was deleted.

5 changes: 0 additions & 5 deletions root/app/fail2ban/jail.d/alpine-ssh.local

This file was deleted.

7 changes: 0 additions & 7 deletions root/app/fail2ban/jail.d/caddy-4xx.local

This file was deleted.

8 changes: 0 additions & 8 deletions root/app/fail2ban/jail.d/jellyfin.local

This file was deleted.

7 changes: 0 additions & 7 deletions root/app/fail2ban/jail.d/jellyseerr.local

This file was deleted.

7 changes: 0 additions & 7 deletions root/app/fail2ban/jail.d/overseerr.local

This file was deleted.

7 changes: 0 additions & 7 deletions root/app/fail2ban/jail.d/petio.local

This file was deleted.

16 changes: 0 additions & 16 deletions root/app/logrotate/jellyfin

This file was deleted.

4 changes: 0 additions & 4 deletions root/app/templates/README

This file was deleted.

15 changes: 0 additions & 15 deletions root/app/templates/conreq

This file was deleted.

14 changes: 0 additions & 14 deletions root/app/templates/jellyfin

This file was deleted.

15 changes: 0 additions & 15 deletions root/app/templates/overseerr

This file was deleted.

15 changes: 0 additions & 15 deletions root/app/templates/petio

This file was deleted.

42 changes: 1 addition & 41 deletions root/etc/cont-init.d/01-config-app
Original file line number Diff line number Diff line change
Expand Up @@ -11,44 +11,4 @@ if [[ ! -f "${CONFIG_DIR}/Caddyfile" ]]; then
chown hotio:hotio "${CONFIG_DIR}/Caddyfile"
fi

if [[ ! -d "${CONFIG_DIR}/fail2ban" ]]; then
echo "Installing default \"fail2ban\"..."
cp -R "${APP_DIR}/fail2ban" "${CONFIG_DIR}/"
chown -R hotio:hotio "${CONFIG_DIR}/fail2ban"
fi

if [[ -f "${CONFIG_DIR}/fail2ban/fail2ban.sqlite3" ]]; then
chown hotio:hotio "${CONFIG_DIR}/fail2ban/fail2ban.sqlite3"
fi

if [[ ! -f "${APP_DIR}/templates/.copied" ]]; then
echo "Installing default \"templates\"..."
rm -rf "${CONFIG_DIR}/templates"
cp -R "${APP_DIR}/templates" "${CONFIG_DIR}/"
chown -R hotio:hotio "${CONFIG_DIR}/templates"
touch "${APP_DIR}/templates/.copied"
fi

if [[ ! -d "${CONFIG_DIR}/crontab" ]]; then
echo "Installing default \"crontab\"..."
cp -R "${APP_DIR}/crontab" "${CONFIG_DIR}/"
chown -R hotio:hotio "${CONFIG_DIR}/crontab"
fi

if [[ -f "${CONFIG_DIR}/crontab/default" ]]; then
echo "Loading user provided \"crontab\" to system..."
crontab "${CONFIG_DIR}/crontab/default"
fi

if [[ ! -d "${CONFIG_DIR}/logrotate" ]]; then
echo "Installing default \"logrotate\"..."
cp -R "${APP_DIR}/logrotate" "${CONFIG_DIR}/"
chown -R hotio:hotio "${CONFIG_DIR}/logrotate"
fi

if [[ -d "${CONFIG_DIR}/logrotate" ]]; then
echo "Copying \"logrotate\" folder to /tmp and chown as root..."
rm -rf "/tmp/logrotate"
cp -R "${CONFIG_DIR}/logrotate" "/tmp/"
chown -R root:root "/tmp/logrotate"
fi
ln -sf "${APP_DIR}/caddy" "/usr/local/bin/caddy"
6 changes: 0 additions & 6 deletions root/etc/services.d/cronie/run

This file was deleted.

6 changes: 0 additions & 6 deletions root/etc/services.d/fail2ban/run

This file was deleted.

0 comments on commit 2b48124

Please sign in to comment.