Add docker deployment
Some checks failed
build docker image / docker-build (push) Has been cancelled
Some checks failed
build docker image / docker-build (push) Has been cancelled
This commit is contained in:
parent
7aaa365cc9
commit
77364f8e25
34
.gitea/workflows/build-docker-image.yaml
Normal file
34
.gitea/workflows/build-docker-image.yaml
Normal file
@ -0,0 +1,34 @@
|
||||
name: build docker image
|
||||
|
||||
on:
|
||||
- push
|
||||
|
||||
jobs:
|
||||
docker-build:
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: catthehacker/ubuntu:act-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Login to GitHub Container Registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: gitea.stuzer.link
|
||||
username: ${{ gitea.repository_owner }}
|
||||
password: ${{ secrets.DOCKER_REGISTRY_TOKEN }}
|
||||
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
platforms: linux/amd64
|
||||
push: true
|
||||
tags: gitea.stuzer.link/stuzer05/random-web-tools:latest
|
||||
cache-from: type=registry,ref=gitea.stuzer.link/stuzer05/random-web-tools:latest
|
||||
cache-to: type=inline
|
112
Dockerfile
112
Dockerfile
@ -1,29 +1,95 @@
|
||||
FROM debian:bullseye-slim
|
||||
FROM php:8.3-fpm
|
||||
|
||||
ENV DEBIAN_FRONTEND="noninteractive"
|
||||
# build arguments
|
||||
ARG APP_URL http://localhost
|
||||
|
||||
RUN apt-get update && apt-get -y upgrade \
|
||||
&& apt-get -y install \
|
||||
curl nodejs npm \
|
||||
&& npm install -g vue vite n \
|
||||
&& n stable \
|
||||
&& mkdir /app \
|
||||
&& rm -rf /var/lib/apt/lists/* /usr/share/man/* /usr/share/doc/*
|
||||
# Update to Debian Trixie
|
||||
RUN cat <<EOF >> /etc/apt/sources.list
|
||||
deb http://deb.debian.org/debian trixie main contrib non-free
|
||||
deb http://deb.debian.org/debian trixie-updates main contrib non-free
|
||||
deb http://security.debian.org/debian-security trixie-security main contrib non-free
|
||||
EOF
|
||||
|
||||
WORKDIR /app
|
||||
# Install system dependencies
|
||||
RUN apt-get update && \
|
||||
apt-get upgrade -y
|
||||
|
||||
COPY ./public public
|
||||
COPY ./src src
|
||||
COPY ./config.prod.js ./config.js
|
||||
COPY ./index.html .
|
||||
COPY ./package.json .
|
||||
COPY ./package-lock.json .
|
||||
COPY ./postcss.config.js .
|
||||
COPY ./tailwind.config.js .
|
||||
COPY ./vite.config.js .
|
||||
# Install apps
|
||||
RUN apt-get install -y --no-install-recommends \
|
||||
nginx \
|
||||
rsyslog \
|
||||
supervisor \
|
||||
curl \
|
||||
wget \
|
||||
npm \
|
||||
nano \
|
||||
cmake \
|
||||
gettext \
|
||||
unzip
|
||||
|
||||
RUN npm install && npm run build
|
||||
# Install PHP dependencies
|
||||
RUN apt-get install -y --no-install-recommends \
|
||||
libzip-dev \
|
||||
libfreetype6=2.12.1+dfsg-5+deb12u3 \
|
||||
libfreetype-dev=2.12.1+dfsg-5+deb12u3 \
|
||||
libpng-dev \
|
||||
libjpeg62-turbo-dev \
|
||||
libwebp-dev \
|
||||
libmcrypt-dev \
|
||||
libbz2-dev \
|
||||
libcurl4-openssl-dev \
|
||||
libtidy-dev \
|
||||
libxslt-dev \
|
||||
libonig-dev \
|
||||
libc-client-dev \
|
||||
libpq-dev \
|
||||
libkrb5-dev \
|
||||
libsqlite3-dev \
|
||||
freetds-dev \
|
||||
freetds-bin
|
||||
|
||||
FROM nginx
|
||||
COPY --from=0 /app/dist /usr/share/nginx/html
|
||||
COPY ./nginx/conf /etc/nginx/conf.d/
|
||||
# Cleanup APT
|
||||
RUN rm -rf \
|
||||
/var/lib/apt/lists/* \
|
||||
/usr/share/man/* \
|
||||
/usr/share/doc/* \
|
||||
/etc/nginx/sites-enabled
|
||||
|
||||
# Install PHP extensions
|
||||
RUN docker-php-ext-install \
|
||||
mbstring \
|
||||
xml \
|
||||
dom \
|
||||
zip \
|
||||
intl \
|
||||
gd \
|
||||
curl \
|
||||
calendar \
|
||||
pdo_sqlite \
|
||||
bcmath
|
||||
|
||||
# Install Node.js
|
||||
RUN npm install -g n && n 18
|
||||
|
||||
# Apply configs
|
||||
COPY ./docker/conf/* /
|
||||
|
||||
# Configure project
|
||||
WORKDIR /tmp
|
||||
|
||||
# Install project
|
||||
COPY . .
|
||||
|
||||
RUN npm install \
|
||||
&& npm run build \
|
||||
&& mv /tmp/dist/* /tmp/api /var/www/html
|
||||
|
||||
WORKDIR /var/www/html
|
||||
|
||||
RUN cp config.js.ci config.js \
|
||||
&& sed -i "s/{APP_URL}/$APP_URL/g" config.js \
|
||||
&& chown www-data:www-data . -R
|
||||
|
||||
COPY ./entrypoint.sh /
|
||||
|
||||
CMD ["/bin/bash", "/entrypoint.sh"]
|
||||
|
5
config.js.ci
Normal file
5
config.js.ci
Normal file
@ -0,0 +1,5 @@
|
||||
const config = {
|
||||
APP_URL: '{APP_URL}',
|
||||
};
|
||||
|
||||
export { config };
|
30
docker/conf/etc/nginx/sites-enabled/default.conf
Normal file
30
docker/conf/etc/nginx/sites-enabled/default.conf
Normal file
@ -0,0 +1,30 @@
|
||||
server {
|
||||
listen 80;
|
||||
server_name default;
|
||||
|
||||
root /var/www/html;
|
||||
index index.php;
|
||||
|
||||
client_max_body_size 5m;
|
||||
client_body_timeout 60;
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/ @rewrite;
|
||||
}
|
||||
|
||||
location @rewrite {
|
||||
rewrite ^/(.*)$ /index.php;
|
||||
}
|
||||
|
||||
location ~ \.php$ {
|
||||
include fastcgi_params;
|
||||
fastcgi_pass unix:/run/php/php-fpm.sock;
|
||||
fastcgi_param SCRIPT_FILENAME $request_filename;
|
||||
}
|
||||
|
||||
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
|
||||
try_files $uri /index.php;
|
||||
expires max;
|
||||
log_not_found off;
|
||||
}
|
||||
}
|
29
docker/conf/etc/supervisor/supervisord.conf
Normal file
29
docker/conf/etc/supervisor/supervisord.conf
Normal file
@ -0,0 +1,29 @@
|
||||
[supervisord]
|
||||
logfile=/var/log/supervisord.log
|
||||
logfile_maxbytes=50MB
|
||||
childlogdir=/var/log
|
||||
pidfile=/var/run/supervisord.pid
|
||||
nodaemon=true
|
||||
user=root
|
||||
|
||||
[supervisorctl]
|
||||
|
||||
[program:misc-rsyslog]
|
||||
command=/usr/sbin/rsyslogd -n
|
||||
autostart=true
|
||||
autorestart=true
|
||||
stdout_logfile=/var/log/supervisor/%(program_name)s.log
|
||||
stderr_logfile=/var/log/supervisor/%(program_name)s.log
|
||||
|
||||
[group:webserver]
|
||||
programs=webserver-nginx,webserver-phpfpm
|
||||
|
||||
[program:webserver-nginx]
|
||||
command=/usr/sbin/nginx -g 'daemon off;'
|
||||
autostart=true
|
||||
autorestart=true
|
||||
|
||||
[program:webserver-phpfpm]
|
||||
command=/usr/local/sbin/php-fpm --nodaemonize --fpm-config /usr/local/etc/php-fpm.d/www.conf
|
||||
autostart=true
|
||||
autorestart=true
|
5
entrypoint.sh
Normal file
5
entrypoint.sh
Normal file
@ -0,0 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
mkdir -p /run/php
|
||||
|
||||
/usr/bin/supervisord -c /etc/supervisor/supervisord.conf
|
@ -1,23 +0,0 @@
|
||||
server {
|
||||
listen 80;
|
||||
listen [::]:80;
|
||||
server_name localhost;
|
||||
|
||||
#access_log /var/log/nginx/host.access.log main;
|
||||
|
||||
location / {
|
||||
root /usr/share/nginx/html;
|
||||
index index.html index.htm;
|
||||
}
|
||||
|
||||
location ~ /map/\d+$ {
|
||||
try_files $uri $uri/ /index.html;
|
||||
}
|
||||
|
||||
# redirect server error pages to the static page /50x.html
|
||||
#
|
||||
error_page 500 502 503 504 /50x.html;
|
||||
location = /50x.html {
|
||||
root /usr/share/nginx/html;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user