-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Docker #88
Draft
SimonFrank14
wants to merge
31
commits into
SchulIT:master
Choose a base branch
from
SimonFrank14:docker-image
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Docker #88
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
99a2226
ci: added docker image for idp
SimonFrank14 42edb49
Improvments for Docker Image
SimonFrank14 e321da7
Merge branch 'SchulIT:master' into docker-image
SimonFrank14 e925105
Set no-dev flag for composer install
SimonFrank14 3e4d08d
Create docker-image.yml
SimonFrank14 3aa7f55
Merge pull request #1 from SimonFrank14/docker-image
SimonFrank14 d00535b
Update docker-image.yml
SimonFrank14 51cef3d
Update docker-image.yml
SimonFrank14 6ccc5f9
Update docker-image.yml
SimonFrank14 46d0614
Added Github Action to automatically build image (#2)
SimonFrank14 752f3cb
Added restart prop to web container
SimonFrank14 0920017
Merge branch 'docker-image' of https://github.com/SimonFrank14/idp in…
SimonFrank14 d3a0be9
boost startup of web container after db ready
SimonFrank14 66102ad
added docker installation docu
SimonFrank14 07d49cc
Docker image (#3)
SimonFrank14 282c253
nginx fix
SimonFrank14 4c4476f
remove no dev flag temp
SimonFrank14 65338de
Merge branch 'master' into docker-image
SimonFrank14 e6930f1
Docker image (#4)
SimonFrank14 1ef6d47
Update docker-image.yml
SimonFrank14 a24d4c1
Update docker-image.yml
SimonFrank14 58e3c4e
Merge branch 'SchulIT:master' into master
SimonFrank14 2b0ff79
Update docker-image.yml
SimonFrank14 580d854
Update docker-image.yml
SimonFrank14 20e68f0
Update docker-image.yml
SimonFrank14 4139d1c
Update docker-image.yml
SimonFrank14 d8c5208
some optimizations for the docker build image
SimonFrank14 1956310
Merge branch 'master' into docker-image
SimonFrank14 336aab5
Update docker-image.yml (#5)
SimonFrank14 adc6b0a
fixed filesystem permission issue
SimonFrank14 05f1ead
Cache was not included in chown
SimonFrank14 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,124 @@ | ||
# Use the official PHP image with FPM as the base image | ||
FROM php:8.2-fpm AS base | ||
|
||
# Install dependencies and PHP extensions | ||
RUN apt-get update && apt-get install -y \ | ||
unzip \ | ||
libxml2-dev \ | ||
libssl-dev \ | ||
libzip-dev \ | ||
libpng-dev \ | ||
libfreetype6-dev \ | ||
libjpeg62-turbo-dev \ | ||
libonig-dev \ | ||
libxslt1-dev \ | ||
libmcrypt-dev \ | ||
libsodium-dev \ | ||
nginx \ | ||
openssl \ | ||
&& docker-php-ext-configure gd --with-freetype --with-jpeg \ | ||
&& docker-php-ext-install -j$(nproc) \ | ||
ctype \ | ||
dom \ | ||
filter \ | ||
iconv \ | ||
intl \ | ||
mbstring \ | ||
pdo_mysql \ | ||
phar \ | ||
simplexml \ | ||
sodium \ | ||
xml \ | ||
xmlwriter \ | ||
zip \ | ||
gd \ | ||
xsl \ | ||
&& apt-get clean \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
# Set memory limit for PHP | ||
RUN echo "memory_limit=512M" > /usr/local/etc/php/conf.d/memory-limit.ini | ||
ENV PHP_MEMORY_LIMIT=512M | ||
|
||
FROM base AS composer | ||
|
||
# Install Composer | ||
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer | ||
|
||
# Set COMPOSER_ALLOW_SUPERUSER environment variable | ||
ENV COMPOSER_ALLOW_SUPERUSER=1 | ||
|
||
# Set working directory | ||
WORKDIR /var/www/html | ||
|
||
# Copy the composer.json and composer.lock files into the container | ||
COPY . . | ||
|
||
# Install PHP dependencies including symfony/runtime | ||
RUN composer install --classmap-authoritative --no-scripts | ||
|
||
FROM base AS node | ||
|
||
# Set working directory | ||
WORKDIR /var/www/html | ||
|
||
COPY --from=composer /var/www/html/vendor /var/www/html/vendor | ||
|
||
# Copy the package.json and package-lock.json files into the container | ||
COPY . . | ||
|
||
# Install Node.js dependencies | ||
RUN apt-get update && apt-get install -y \ | ||
curl \ | ||
&& apt-get clean \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
# Install Node.js and npm | ||
RUN curl -fsSL https://deb.nodesource.com/setup_18.x | bash - \ | ||
&& apt-get install -y nodejs \ | ||
&& npm install -g npm@latest | ||
|
||
# Install Node.js dependencies and build assets | ||
RUN npm install \ | ||
&& npm run build \ | ||
&& php bin/console assets:install | ||
|
||
FROM base AS runner | ||
|
||
# Copy necessary files into the container | ||
#COPY bin /var/www/html/bin | ||
#COPY .env /var/www/html/.env | ||
#COPY templates /var/www/html/templates | ||
#COPY migrations /var/www/html/migrations | ||
#COPY config /var/www/html/config | ||
#COPY src /var/www/html/src | ||
#COPY public /var/www/html/public | ||
COPY . . | ||
|
||
# Copy build files from the previous stages | ||
COPY --from=node /var/www/html/public /var/www/html/public | ||
COPY --from=composer /var/www/html/vendor /var/www/html/vendor | ||
|
||
WORKDIR /var/www/html | ||
|
||
# Create SAML certificate | ||
RUN php bin/console app:create-certificate --type saml --no-interaction | ||
|
||
# Copy the Nginx configuration file into the container | ||
COPY default.conf /etc/nginx/sites-enabled/sso | ||
# COPY default.conf /etc/nginx/conf.d/default.conf | ||
|
||
# Copy the startup script into the container | ||
COPY startup.sh /usr/local/bin/startup.sh | ||
|
||
# Ensure the startup script is executable | ||
RUN chmod +x /usr/local/bin/startup.sh | ||
|
||
# Set first run flag | ||
ENV FIRST_RUN=1 | ||
|
||
# Expose port 80 | ||
EXPOSE 80 | ||
|
||
# Use the startup script as the entrypoint | ||
CMD ["/usr/local/bin/startup.sh"] |
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,56 @@ | ||
server { | ||
listen 80; | ||
server_name localhost; | ||
|
||
root /var/www/html/public; | ||
|
||
location / { | ||
# try to serve file directly, fallback to index.php | ||
try_files $uri /index.php$is_args$args; | ||
} | ||
|
||
# optionally disable falling back to PHP script for the asset directories; | ||
# nginx will return a 404 error when files are not found instead of passing the | ||
# request to Symfony (improves performance but Symfony's 404 page is not displayed) | ||
# location /bundles { | ||
# try_files $uri =404; | ||
# } | ||
|
||
location ~ ^/index\.php(/|$) { | ||
fastcgi_pass 127.0.0.1:9000; | ||
fastcgi_split_path_info ^(.+\.php)(/.*)$; | ||
include fastcgi_params; | ||
|
||
# When you are using symlinks to link the document root to the | ||
# current version of your application, you should pass the real | ||
# application path instead of the path to the symlink to PHP | ||
# FPM. | ||
# Otherwise, PHP's OPcache may not properly detect changes to | ||
# your PHP files (see https://github.com/zendtech/ZendOptimizerPlus/issues/126 | ||
# for more information). | ||
# Caveat: When PHP-FPM is hosted on a different machine from nginx | ||
# $realpath_root may not resolve as you expect! In this case try using | ||
# $document_root instead. | ||
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; | ||
fastcgi_param DOCUMENT_ROOT $realpath_root; | ||
|
||
proxy_set_header Host $http_host; | ||
proxy_set_header X-Real-IP $remote_addr; | ||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
proxy_set_header X-Forwarded-Proto $scheme; | ||
# Prevents URIs that include the front controller. This will 404: | ||
# http://domain.tld/index.php/some-path | ||
# Remove the internal directive to allow URIs like this | ||
# internal; | ||
} | ||
|
||
# return 404 for all other php files not matching the front controller | ||
# this prevents access to other php files you don't want to be accessible. | ||
location ~ \.php$ { | ||
return 404; | ||
} | ||
|
||
# Optional logging | ||
error_log /var/log/nginx/error.log; | ||
access_log /var/log/nginx/access.log; | ||
} |
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,29 @@ | ||
version: '3.8' | ||
|
||
services: | ||
web: | ||
build: . | ||
ports: | ||
- "8080:80" | ||
depends_on: | ||
- db | ||
env_file: | ||
- .env.local | ||
|
||
db: | ||
image: mariadb:10.4 | ||
restart: always | ||
environment: | ||
MYSQL_ROOT_PASSWORD: rootpassword | ||
MYSQL_DATABASE: idp | ||
MYSQL_USER: idpuser | ||
MYSQL_PASSWORD: idppassword | ||
ports: | ||
- "3306:3306" | ||
volumes: | ||
- db_data:/var/lib/mysql | ||
|
||
volumes: | ||
db_data: | ||
|
||
|
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,25 @@ | ||
#!/bin/sh | ||
|
||
# Check if the FIRST_RUN environment variable is 1 | ||
if [ "$FIRST_RUN" = "1" ]; then | ||
# Run database migrations | ||
php bin/console doctrine:migrations:migrate --no-interaction | ||
|
||
# Perform initial setup | ||
php bin/console app:setup | ||
|
||
# Register cron jobs | ||
php bin/console shapecode:cron:scan | ||
|
||
# Update Browscap | ||
php bin/console app:browscap:update | ||
|
||
# Set FIRST_RUN environment variable to 0 | ||
export FIRST_RUN=0 | ||
fi | ||
|
||
# Start PHP-FPM | ||
php-fpm & | ||
|
||
# Start Nginx | ||
nginx -g 'daemon off;' |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
--no-dev Flag hinzufügen, wenn fertig mit testen