mirror of
https://github.com/Eggbertx/gochan.git
synced 2025-08-08 19:36:24 -07:00
Remove no longer used build-image.sh and update startup.sh to build the execcutable if it doesn't exist
This commit is contained in:
parent
02e8be97cc
commit
96e8e07f10
7 changed files with 28 additions and 78 deletions
|
@ -1,10 +1,7 @@
|
|||
FROM golang:1.20-alpine3.18
|
||||
|
||||
COPY docker/build-image.sh .
|
||||
|
||||
WORKDIR /opt/gochan
|
||||
|
||||
# Get all
|
||||
COPY . .
|
||||
|
||||
RUN apk add \
|
||||
|
@ -16,12 +13,12 @@ RUN apk add \
|
|||
musl-dev \
|
||||
openssl \
|
||||
exiftool && \
|
||||
mkdir -p /var/www/ && \
|
||||
ln -sn /opt/gochan/html/* /var/www/
|
||||
|
||||
mkdir -p /var/www/gochan && \
|
||||
ln -sn /opt/gochan/html/* /var/www/gochan/
|
||||
|
||||
COPY docker/gochan-docker.json /etc/gochan/gochan.json
|
||||
|
||||
RUN ["./build.py"]
|
||||
ENV DBTYPE=mysql
|
||||
ENV DATABASE_HOST=gochan-mariadb
|
||||
ENV DATABASE_PORT=3306
|
||||
|
||||
CMD ["/opt/gochan/docker/startup.sh"]
|
||||
|
|
|
@ -1,15 +1,7 @@
|
|||
To run docker you have several choices.
|
||||
# Docker info
|
||||
Previously, gochan's default docker-compose.yml was divided into two services, gochan+nginx and db, which mainly supported MariaDB. Now, there are four options for docker-compose, one for each database provider (with MySQL separately). The SyncForMac container file appears to have been incomplete so it has been removed since I am unable to test its usefulness.
|
||||
|
||||
If you want the docker container to use the host's database, copy `docker-compose.yml.default` to `docker-compose.yml` and edit the new file with your host's information.
|
||||
Nginx has also been removed, as it is not really necessary to run a gochan server. It is only really necessary if you want to serve HTTPS (which you should). For a dev environment, you can just use any of the provided docker-compose files. For a production server, you can run nginx outside Docker (or in a separate container) and just forward ports accordingly.
|
||||
|
||||
If you want docker to manage the databse, use `docker-compose-[database].yml`.
|
||||
|
||||
If you are using MacOS and need better file sync between the host and the container, use `docker-compose-syncForMac.yml`.
|
||||
|
||||
To use from the root gochan directory, run `./build.py docker`, or `./build.py docker ---option macos` if you are using MacOS. This will use the MariaDB docker-compose file. If you want to specify which docker-compose file to use, run `docker-compose -f [docker-compose.yml file you chose] up --build` from this directory. To stop, simply use control+c to send a stop signal. This stops the docker containers but it does not delete them. They are merely frozen.
|
||||
|
||||
To delete the containers run `docker-compose -f [file you chose] down`. If you have a container that has a database (for example, if you chose `docker-compose-mariadb.yml`), this command will delete the database too.
|
||||
|
||||
If you want to use a specific docker-compose file as the default for your own computer, or you want to edit one of the default configurations given here (to change the database type, for example), copy the file and name it `docker-compose.yml`. This way, you can omit specifying the file when using docker-compose. For example, `docker-compose down` is the same as `docker-compose -f docker-compose.yml down`. The file is added to .gitignore so that your local config won't be accidentally commited.
|
||||
|
||||
Docker caches builds. When files change, it has to rebuild from whenever that file was added to the docker image. For example, the docker file adds `build.py` at first and ignores the rest of the files. It uses it to download the dependencies, which can take a while. After that, it adds the rest of the files. This means that if a file is changed in a source file, docker won't have to rebuild. But if build.py changes, it will be forced to rebuild. This can cause Docker to bloat up after a while. Periodically remember to run `docker image prune` (also search for other deletion commands) to keep docker's storage usage relatively low. All images used thus far use Alpine, which is a small OS compared to Ubuntu or other much larger builds.
|
||||
## Usage
|
||||
TODO
|
|
@ -1,10 +0,0 @@
|
|||
[mysqld]
|
||||
user = root
|
||||
datadir = /app/mysql
|
||||
port = 3306
|
||||
log-bin = /app/mysql/mysql-bin
|
||||
bind-address = 0.0.0.0
|
||||
max_allowed_packet=256M
|
||||
|
||||
# Disabling symbolic-links is recommended to prevent assorted security risks
|
||||
symbolic-links=0
|
|
@ -1,36 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
apk add \
|
||||
mariadb-client \
|
||||
nginx \
|
||||
ffmpeg \
|
||||
python3 \
|
||||
git \
|
||||
gcc \
|
||||
musl-dev \
|
||||
openssl \
|
||||
exiftool
|
||||
|
||||
mkdir -p /root/bin
|
||||
|
||||
ln -s /usr/lib/go-1.20/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=127.0.0.1"
|
|
@ -9,16 +9,9 @@ services:
|
|||
volumes:
|
||||
- ../:/opt/gochan # note: this doesn't work too well in MacOS.
|
||||
- ./volumes/gochan/log:/var/log/gochan
|
||||
- ./volumes/gochan/www:/var/www
|
||||
- ./volumes/gochan/www:/var/www/gochan
|
||||
networks:
|
||||
- gochan-bridge
|
||||
environment:
|
||||
- DBTYPE=mysql
|
||||
- DATABASE_HOST=gochan-mariadb
|
||||
- DATABASE_PORT=3306
|
||||
- DATABASE_NAME=gochan
|
||||
- DATABASE_USER=gochan
|
||||
- DATABASE_PASSWORD=gochan
|
||||
depends_on:
|
||||
- mariadb
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
"ListenIP": "gochan-server",
|
||||
"Port": 80,
|
||||
"UseFastCGI": false,
|
||||
"DocumentRoot": "/var/www",
|
||||
"DocumentRoot": "/var/www/gochan",
|
||||
"TemplateDir": "/opt/gochan/templates",
|
||||
"LogDir": "/var/log/gochan",
|
||||
"Plugins": null,
|
||||
|
|
|
@ -2,6 +2,20 @@
|
|||
|
||||
set -euo pipefail
|
||||
|
||||
cd /opt/gochan
|
||||
|
||||
if [ ! -L /var/www/gochan/js ]; then
|
||||
echo "Build stage didn't create links in /var/www/gochan"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -f /etc/gochan/.installed ]; then
|
||||
git config --global --add safe.directory /opt/gochan
|
||||
echo "Creating gochan executable"
|
||||
./build.py
|
||||
touch /etc/gochan/.installed
|
||||
fi
|
||||
|
||||
echo "pinging db, DBTYPE: '$DBTYPE'"
|
||||
/opt/gochan/docker/wait-for.sh "$DATABASE_HOST:$DATABASE_PORT" -t 30
|
||||
/opt/gochan/gochan
|
||||
./docker/wait-for.sh "$DATABASE_HOST:$DATABASE_PORT" -t 30
|
||||
./gochan
|
Loading…
Add table
Add a link
Reference in a new issue