mirror of
https://github.com/Eggbertx/gochan.git
synced 2025-08-27 11:26:22 -07:00
Move chain command in Dockerfile CMD to startup script, update Go version in Docker
This commit is contained in:
parent
4216751847
commit
608ff24d9a
7 changed files with 75 additions and 45 deletions
|
@ -1,54 +1,23 @@
|
|||
FROM golang:1.16-alpine3.15
|
||||
FROM golang:1.18-alpine3.17
|
||||
|
||||
RUN apk --no-cache add \
|
||||
postgresql-client \
|
||||
mariadb-client \
|
||||
nginx \
|
||||
ffmpeg \
|
||||
python3 \
|
||||
git \
|
||||
gcc \
|
||||
musl-dev \
|
||||
openssl \
|
||||
bash
|
||||
COPY docker/build-image.sh .
|
||||
|
||||
RUN mkdir -p /root/bin \
|
||||
&& ln -s /usr/lib/go-1.16/bin/* /root/bin/ \
|
||||
&& export PATH=$PATH:/root/bin \
|
||||
&& echo "export PATH=$PATH:/root/bin" >> /root/.bashrc \
|
||||
&& rm -f /etc/nginx/sites-enabled/* /etc/nginx/sites-available/* \
|
||||
&& mkdir -p /var/lib/nginx \
|
||||
&& mkdir -p /var/lib/nginx/tmp \
|
||||
&& mkdir -p /run/nginx/
|
||||
RUN ["./build-image.sh"]
|
||||
|
||||
WORKDIR /opt/gochan
|
||||
|
||||
# Get dependencies
|
||||
COPY build.py .
|
||||
RUN ./build.py dependencies
|
||||
|
||||
RUN rm -f /etc/nginx/http.d/default.conf
|
||||
COPY sample-configs/gochan-fastcgi.nginx /etc/nginx/http.d/gochan.conf
|
||||
COPY sample-configs/gochan.example.json /etc/gochan/gochan.json
|
||||
|
||||
# Get all
|
||||
COPY . .
|
||||
RUN ["./build.py"]
|
||||
RUN ["./build.py", "install"]
|
||||
|
||||
|
||||
EXPOSE 9000
|
||||
|
||||
# The openssl command will generate self-signed certificate since some browsers like
|
||||
# Firefox and Chrome automatically do HTTPS requests. this will likely show a warning in
|
||||
# the browser, which you can ignore
|
||||
CMD ["ls", "-la", "/opt/gochan", "&&", \
|
||||
"ls", "-la", "&&", \
|
||||
"ls", "-la", "..", "&&", \
|
||||
"sed", "-i", "/etc/gochan/gochan.json", "-e", "s/\"Port\": 8080/\"Port\": 9000/", "-e", "s/\"UseFastCGI\": false/\"UseFastCGI\": true/", "-e", "s/\"Username\": \".*\",//", "-e", "s#\"DocumentRoot\": \"html\"#\"DocumentRoot\": \"/srv/gochan\"#", "-e", "s#\"TemplateDir\": \"templates\"#\"TemplateDir\": \"/usr/share/gochan/templates\"#", "-e", "s#\"LogDir\": \"log\"#\"LogDir\": \"/var/log/gochan\"#", "-e", "s/\"Verbosity\": 0/\"Verbosity\": 1/", "-e", "s/\"DBtype\".*/\"DBtype\": \"${DBTYPE}\",/", "-e", "s/\"DBhost\".*/\"DBhost\": \"tcp(${DATABASE_HOST}:${DATABASE_PORT})\",/", "-e", "s/\"DBname\".*/\"DBname\": \"${DATABASE_NAME}\",/", "-e", "s/\"DBusername\".*/\"DBusername\": \"${DATABASE_USER}\",/", "-e", "s/\"DBpassword\".*/\"DBpassword\": \"${DATABASE_PASSWORD}\",/", "&&", \
|
||||
"mkdir", "-p", "/etc/ssl/private", "&&", \
|
||||
"openssl", "req", "-x509", "-nodes", "-days", "7305", "-newkey", "rsa:2048", "-keyout", "/etc/ssl/private/nginx-selfsigned.key", "-out", "/etc/ssl/certs/nginx-selfsigned.crt", "-subj", "/CN=127.0.0.1", "&&", \
|
||||
"./build.py", "&&", \
|
||||
"./build.py", "install", "&&", \
|
||||
"nginx", "&&", \
|
||||
"echo", "pinging db", "&&", \
|
||||
"docker/wait-for.sh", "$DATABASE_HOST:$DATABASE_PORT", "-t", "30", "&&", \
|
||||
"/opt/gochan/gochan", "-rebuild", "all", "&&", \
|
||||
"/opt/gochan/gochan"]
|
||||
|
||||
COPY docker/startup.sh /opt/gochan/startup.sh
|
||||
COPY docker/wait-for.sh /opt/gochan/wait-for.sh
|
||||
CMD ["/opt/gochan/docker/startup.sh"]
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
FROM alpine:3.9
|
||||
FROM alpine:3.17
|
||||
RUN apk --no-cache add rsync lsyncd
|
||||
# Declared in docker-compose
|
||||
#CMD lsyncd -delay 1 -nodaemon -rsync /source /cache
|
|
@ -1,4 +1,4 @@
|
|||
FROM alpine:3.9
|
||||
FROM alpine:3.17
|
||||
|
||||
WORKDIR /app
|
||||
RUN apk --update add mysql && rm -f /var/cache/apk/*
|
||||
|
|
37
docker/build-image.sh
Executable file
37
docker/build-image.sh
Executable file
|
@ -0,0 +1,37 @@
|
|||
#!/bin/sh
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
apk --no-cache add \
|
||||
postgresql-client \
|
||||
mariadb-client \
|
||||
nginx \
|
||||
ffmpeg \
|
||||
python3 \
|
||||
git \
|
||||
gcc \
|
||||
musl-dev \
|
||||
openssl \
|
||||
bash
|
||||
|
||||
mkdir -p /root/bin
|
||||
|
||||
ln -s /usr/lib/go-1.18/bin/* /root/bin/
|
||||
export PATH=$PATH:/root/bin
|
||||
echo "export PATH=$PATH:/root/bin" >> /root/.bashrc
|
||||
rm -f /etc/nginx/sites-enabled/* /etc/nginx/sites-available/*
|
||||
mkdir -p /var/lib/nginx
|
||||
mkdir -p /var/lib/nginx/tmp
|
||||
mkdir -p /run/nginx/
|
||||
|
||||
rm -f /etc/nginx/http.d/default.conf
|
||||
|
||||
|
||||
# The openssl command will generate self-signed certificate since some browsers like
|
||||
# Firefox and Chrome automatically do HTTPS requests. this will likely show a warning in
|
||||
# the browser, which you can ignore
|
||||
mkdir -p /etc/ssl/private
|
||||
openssl req -x509 -nodes -days 7305 -newkey rsa:2048 \
|
||||
-keyout /etc/ssl/private/nginx-selfsigned.key \
|
||||
-out /etc/ssl/certs/nginx-selfsigned.crt \
|
||||
-subj "/CN=192.168.56.3"
|
|
@ -9,7 +9,7 @@ services:
|
|||
- "80:80"
|
||||
- "443:443"
|
||||
environment:
|
||||
- DBTYPE=mysql # change this to 'postgresql' if needed
|
||||
- DBTYPE=mysql # change this to 'postgresql' or 'sqlite3' if needed
|
||||
- DATABASE_HOST=host.docker.internal
|
||||
- DATABASE_PORT=3306
|
||||
- DATABASE_NAME=gochan
|
||||
|
|
|
@ -10,7 +10,7 @@ services:
|
|||
volumes:
|
||||
- ../:/opt/gochan # note: this doesn't work too well in MacOS.
|
||||
environment:
|
||||
- DBTYPE=mysql # change this to 'postgresql' if needed
|
||||
- DBTYPE=mysql # change this to 'postgresql' or 'sqlite3' if needed
|
||||
- DATABASE_HOST=host.docker.internal
|
||||
- DATABASE_PORT=3306
|
||||
- DATABASE_NAME=gochan
|
||||
|
|
24
docker/startup.sh
Executable file
24
docker/startup.sh
Executable file
|
@ -0,0 +1,24 @@
|
|||
#!/bin/sh
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
sed -i "/etc/gochan/gochan.json" \
|
||||
-e "s/\"Port\": 8080/\"Port\": 9000/" \
|
||||
-e "s/\"UseFastCGI\": false/\"UseFastCGI\": true/" \
|
||||
-e "s/\"Username\": \".*\",//" \
|
||||
-e "s#\"DocumentRoot\": \"html\"#\"DocumentRoot\": \"/srv/gochan\"#" \
|
||||
-e "s#\"TemplateDir\": \"templates\"#\"TemplateDir\": \"/usr/share/gochan/templates\"#" \
|
||||
-e "s#\"LogDir\": \"log\"#\"LogDir\": \"/var/log/gochan\"#" \
|
||||
-e "s/\"Verbosity\": 0/\"Verbosity\": 1/" \
|
||||
-e "s/\"DBtype\".*/\"DBtype\": \"${DBTYPE}\",/" \
|
||||
-e "s/\"DBhost\".*/\"DBhost\": \"tcp(${DATABASE_HOST}:${DATABASE_PORT})\",/" \
|
||||
-e "s/\"DBname\".*/\"DBname\": \"${DATABASE_NAME}\",/" \
|
||||
-e "s/\"DBusername\".*/\"DBusername\": \"${DATABASE_USER}\",/" \
|
||||
-e "s/\"DBpassword\".*/\"DBpassword\": \"${DATABASE_PASSWORD}\",/"
|
||||
|
||||
nginx
|
||||
echo "pinging db, DBTYPE: '$DBTYPE'"
|
||||
|
||||
/opt/gochan/docker/wait-for.sh "$DATABASE_HOST:$DATABASE_PORT" -t 30
|
||||
/opt/gochan/gochan -rebuild all
|
||||
/opt/gochan/gochan
|
Loading…
Add table
Add a link
Reference in a new issue