-
Notifications
You must be signed in to change notification settings - Fork 341
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(#146) Re-wrote the docker code to generate a single self-contained d… (
#153) * (#146) Re-wrote the docker code to generate a single self-contained docker image rather than using a docker-compose network of connected containers * (#146) Push version tags to docker hub automatically * (#146) Switched to using a multistage docker build process to make the Dockerfile more readable and cache friendly without bloating the published image * #146 More readable names * #146 Documented the upgrade process and made 'artisan migrate' run on every boot to automate the upgrade process.
- Loading branch information
Showing
14 changed files
with
413 additions
and
174 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.git | ||
Dockerfile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,62 @@ | ||
POSTGRES_USER="postgres" | ||
POSTGRES_PASSWORD="postgres" | ||
POSTGRES_DB="postgres" | ||
|
||
DB_HOST="database" | ||
DB_DATABASE="postgres" | ||
DB_USERNAME="postgres" | ||
DB_PASSWORD="postgres" | ||
APP_NAME="OpnForm" | ||
APP_ENV=local | ||
APP_KEY= | ||
APP_DEBUG=false | ||
APP_LOG_LEVEL=debug | ||
APP_URL=http://localhost | ||
|
||
LOG_CHANNEL=errorlog | ||
LOG_LEVEL=debug | ||
|
||
DB_CONNECTION=pgsql | ||
DB_HOST=127.0.0.1 | ||
DB_PORT=5432 | ||
DB_DATABASE=postgres | ||
DB_USERNAME=postgres | ||
DB_PASSWORD=postgres | ||
|
||
FILESYSTEM_DRIVER=s3 | ||
FILESYSTEM_DISK=s3 | ||
|
||
BROADCAST_DRIVER=log | ||
CACHE_DRIVER=redis | ||
QUEUE_CONNECTION=redis | ||
SESSION_DRIVER=file | ||
SESSION_LIFETIME=120 | ||
|
||
REDIS_HOST=127.0.0.1 | ||
REDIS_PASSWORD=null | ||
REDIS_PORT=6379 | ||
|
||
MAIL_MAILER=smtp | ||
MAIL_HOST=smtp.mailtrap.io | ||
MAIL_PORT=2525 | ||
MAIL_USERNAME=null | ||
MAIL_PASSWORD=null | ||
MAIL_ENCRYPTION=null | ||
MAIL_FROM_ADDRESS=null | ||
MAIL_FROM_NAME="${APP_NAME}" | ||
|
||
AWS_ACCESS_KEY_ID= | ||
AWS_SECRET_ACCESS_KEY= | ||
AWS_DEFAULT_REGION=us-east-1 | ||
AWS_BUCKET= | ||
|
||
PUSHER_APP_ID= | ||
PUSHER_APP_KEY= | ||
PUSHER_APP_SECRET= | ||
PUSHER_APP_CLUSTER=mt1 | ||
|
||
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}" | ||
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}" | ||
|
||
JWT_TTL=1440 | ||
JWT_SECRET= | ||
|
||
STRIPE_KEY= | ||
STRIPE_SECRET= | ||
|
||
MUX_WORKSPACE_ID= | ||
MUX_API_TOKEN= | ||
|
||
OPEN_AI_API_KEY= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: Publish Docker image | ||
|
||
on: | ||
push: | ||
tags: | ||
- "v*" | ||
|
||
jobs: | ||
push_to_registry: | ||
name: Push Docker image to Docker Hub | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Get tag name | ||
run: ( echo "TAG_NAME=${GITHUB_REF#refs/*/v}"; echo "DOCKER_REPO=${{secrets.DOCKER_REPO}}") >> $GITHUB_ENV | ||
|
||
- name: Check out the repo | ||
uses: actions/checkout@v3 | ||
|
||
- name: Log in to Docker Hub | ||
run: docker login -u "${{ secrets.DOCKER_USERNAME }}" -p "${{ secrets.DOCKER_ACCESS_TOKEN }}" | ||
|
||
- name: Build docker image | ||
run: docker build . -t $DOCKER_REPO:latest -t $DOCKER_REPO:$TAG_NAME | ||
|
||
- name: Push Docker image | ||
run: docker push $DOCKER_REPO:latest && docker push $DOCKER_REPO:$TAG_NAME |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
ARG PHP_PACKAGES="php8.1 composer php8.1-common php8.1-pgsql php8.1-redis php8.1-mbstring\ | ||
php8.1-simplexml php8.1-bcmath php8.1-gd php8.1-curl php8.1-zip\ | ||
php8.1-imagick php8.1-bz2 php8.1-gmp php8.1-int php8.1-pcov php8.1-soap php8.1-xsl" | ||
|
||
FROM node:16 AS javascript-builder | ||
WORKDIR /app | ||
|
||
# It's best to add as few files as possible before running the build commands | ||
# as they will be re-run everytime one of those files changes. | ||
# | ||
# It's possible to run npm install with only the package.json and package-lock.json file. | ||
|
||
ADD package.json package-lock.json ./ | ||
RUN npm install | ||
|
||
ADD resources /app/resources | ||
ADD public /app/public | ||
ADD tailwind.config.js vite.config.js postcss.config.js /app/ | ||
RUN npm run build | ||
|
||
|
||
# syntax=docker/dockerfile:1.3-labs | ||
FROM --platform=linux/amd64 ubuntu:23.04 AS php-dependency-installer | ||
|
||
ARG PHP_PACKAGES | ||
|
||
RUN apt-get update \ | ||
&& apt-get install -y $PHP_PACKAGES composer | ||
|
||
WORKDIR /app | ||
ADD composer.json composer.lock artisan ./ | ||
# Running artisan requires the full php app to be installed so we need to remove the | ||
# post-autoload command from the composer file if we want to run composer without | ||
# adding a dependency to all the php files. | ||
RUN sed 's_@php artisan package:discover_/bin/true_;' -i composer.json | ||
RUN composer install | ||
|
||
ADD app /app/app | ||
ADD bootstrap /app/bootstrap | ||
ADD config /app/config | ||
ADD database /app/database | ||
ADD public public | ||
ADD routes routes | ||
ADD tests tests | ||
|
||
# Manually run the command we deleted from composer.json earlier | ||
RUN php artisan package:discover --ansi | ||
|
||
|
||
FROM --platform=linux/amd64 ubuntu:23.04 | ||
|
||
# supervisord is a process manager which will be responsible for managing the | ||
# various server processes. These are configured in docker/supervisord.conf | ||
|
||
CMD ["/usr/bin/supervisord"] | ||
|
||
WORKDIR /app | ||
|
||
ARG PHP_PACKAGES | ||
|
||
RUN apt-get update \ | ||
&& apt-get install -y \ | ||
supervisor nginx sudo postgresql-15 redis\ | ||
$PHP_PACKAGES php8.1-fpm\ | ||
&& apt-get clean | ||
|
||
ADD docker/postgres-wrapper.sh docker/php-fpm-wrapper.sh docker/redis-wrapper.sh /usr/local/bin/ | ||
ADD docker/php-fpm.conf /etc/php/8.1/fpm/pool.d/ | ||
ADD docker/nginx.conf /etc/nginx/sites-enabled/default | ||
ADD docker/supervisord.conf /etc/supervisor/conf.d/supervisord.conf | ||
ADD .env.docker .env | ||
|
||
ADD . . | ||
|
||
COPY --from=javascript-builder /app/public/build/ ./public/build/ | ||
COPY --from=php-dependency-installer /app/vendor/ ./vendor/ | ||
|
||
RUN chmod a+x /usr/local/bin/*.sh /app/artisan \ | ||
&& ln -s /app/artisan /usr/local/bin/artisan \ | ||
&& useradd opnform \ | ||
&& echo "daemon off;" >> /etc/nginx/nginx.conf\ | ||
&& echo "daemonize no" >> /etc/redis/redis.conf\ | ||
&& echo "appendonly yes" >> /etc/redis/redis.conf\ | ||
&& echo "dir /persist/redis/data" >> /etc/redis/redis.conf | ||
|
||
|
||
EXPOSE 80 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.