Skip to content

Commit

Permalink
First commit
Browse files Browse the repository at this point in the history
  • Loading branch information
antonioanerao committed May 11, 2024
0 parents commit cd1f1b6
Show file tree
Hide file tree
Showing 8 changed files with 2,671 additions and 0 deletions.
91 changes: 91 additions & 0 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
name: Docker

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

on:
schedule:
- cron: '0 0 * * SUN'
push:
branches: [ "main" ]
# Publish semver tags as releases.
tags: [ 'v*.*.*' ]
pull_request:
branches: [ "main" ]

env:
# Use docker.io for Docker Hub if empty
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
IMAGE_NAME: ${{ github.repository }}

jobs:
build:

runs-on: ubuntu-latest
permissions:
contents: read
packages: write
# This is used to complete the identity challenge
# with sigstore/fulcio when running outside of PRs.
id-token: write

steps:
- name: Checkout repository
uses: actions/checkout@v3

# Install the cosign tool except on PR
# https://github.com/sigstore/cosign-installer
- name: Install cosign
if: github.event_name != 'pull_request'
uses: sigstore/cosign-installer@1fc5bd396d372bee37d608f955b336615edf79c8 # v3.2.0

# Workaround: https://github.com/docker/build-push-action/issues/461
- name: Setup Docker buildx
uses: docker/setup-buildx-action@79abd3f86f79a9d68a23c75a09a9a85889262adf

# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

# Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@ac9327eae2b366085ac7f6a2d02df8aa8ead720a
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max

# Sign the resulting Docker image digest except on PRs.
# This will only write to the public Rekor transparency log when the Docker
# repository is public to avoid leaking data. If you would like to publish
# transparency data even for private images, pass --force to cosign below.
# https://github.com/sigstore/cosign
- name: Sign the published Docker image
if: ${{ github.event_name != 'pull_request' }}
env:
COSIGN_EXPERIMENTAL: "true"
# This step uses the identity token to provision an ephemeral certificate
# against the sigstore community Fulcio instance.
run: echo "${{ steps.meta.outputs.tags }}" | xargs -I {} cosign sign -y {}@${{ steps.build-and-push.outputs.digest }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.idea
90 changes: 90 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
FROM nginx

VOLUME [ "/laravel" ]
WORKDIR /laravel
ENV ACCEPT_EULA=Y
ENV LD_LIBRARY_PATH=/usr/lib/oracle/21.1/client64/lib:$LD_LIBRARY_PATH
ENV ORACLE_HOME=/usr/lib/oracle/21.1/client64/lib

# Define a timezone padrão
RUN ln -fs /usr/share/zoneinfo/America/Rio_Branco /etc/localtime && \
dpkg-reconfigure --frontend noninteractive tzdata

# Instala as dependências do sistema
RUN apt update && \
apt -y upgrade && \
echo "pt_BR.UTF-8 UTF-8" > /etc/locale.gen && \
apt install -y ca-certificates \
apt-transport-https \
lsb-release \
gnupg \
curl \
wget \
vim \
dirmngr \
software-properties-common \
rsync \
gettext \
locales \
gcc \
g++ \
make \
unzip \
gcc \
g++ \
autoconf \
libc-dev \
pkg-config

# Define a localização padrão
RUN locale-gen

# Instala o PHP 8.2, suas extensões, node, npm e composer
RUN apt -y update && \
apt -y install --allow-unauthenticated php8.2 \
php8.2-fpm \
php8.2-mysql \
php8.2-mbstring \
php8.2-soap \
php8.2-gd \
php8.2-xml \
php8.2-intl \
php8.2-dev \
php8.2-curl \
php8.2-zip \
php8.2-imagick \
php8.2-gmp \
php8.2-ldap \
php8.2-bcmath \
php8.2-bz2 \
php8.2-phar \
php8.2-sqlite3 && \
curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer && \
curl -s https://deb.nodesource.com/setup_18.x | bash && \
apt-get update && \
apt install nodejs -y

# Instalação do Oracle Instant Client
RUN apt update && apt install -y libaio1 && mkdir -p /opt/oracle && cd /opt/oracle && \
mkdir -p /usr/lib/oracle/21.1/client64 && \
wget https://download.oracle.com/otn_software/linux/instantclient/211000/instantclient-basic-linux.x64-21.1.0.0.0.zip && \
wget https://download.oracle.com/otn_software/linux/instantclient/211000/instantclient-sdk-linux.x64-21.1.0.0.0.zip && \
unzip instantclient-basic-linux.x64-21.1.0.0.0.zip && \
unzip instantclient-sdk-linux.x64-21.1.0.0.0.zip && \
rm -f instantclient-basic-linux.x64-21.1.0.0.0.zip instantclient-sdk-linux.x64-21.1.0.0.0.zip && \
ln -s /opt/oracle/instantclient_21_1 /usr/lib/oracle/21.1/client64/lib && \
cd /usr/lib/oracle/21.1/client64 && \
cp -r lib/sdk . && \
echo "instantclient,/usr/lib/oracle/21.1/client64/lib" | pecl install oci8 && \
echo "extension=oci8.so" > /etc/php/8.2/mods-available/oci8.ini && \
phpenmod -v 8.2 oci8 && \
cd /laravel && \
composer create-project laravel/laravel . && \
chgrp -R www-data /laravel/storage /laravel/bootstrap/cache /laravel/storage/logs && \
chmod -R ug+rwx /laravel/storage /laravel/bootstrap/cache /laravel/storage/logs && \
chown root:www-data -R database && chmod ug+rwx -R database

COPY config_cntr/php.ini /etc/php/8.2/fpm/php.ini
COPY config_cntr/www.conf /etc/php/8.2/fpm/pool.d/www.conf
COPY config_cntr/nginx.conf /etc/nginx
COPY config_cntr/default.conf /etc/nginx/conf.d
53 changes: 53 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
### Docker Image for Laravel Projects

[![Docker](https://github.com/antonioanerao/dockerfile-laravel/actions/workflows/docker-publish.yml/badge.svg)](https://github.com/antonioanerao/dockerfile-laravel/actions/workflows/docker-publish.yml)

#### Nginx Version
1.25.4

#### PHP Version
8.2.7

#### NODE Version
18.20.0

### NPM Version
10.5.0

#### PHP Extensions
php8.2-fpm
php8.2-mbstring
php8.2-soap
php8.2-gd
php8.2-xml
php8.2-intl
php8.2-dev
php8.2-curl
php8.2-zip
php8.2-imagick
php8.2-gmp
php8.2-ldap
php8.2-bcmath
php8.2-bz2
php8.2-phar
php8.2-mysql
php8.2-sqlite3
php8.2-sqlsrv
php8.2-pdo_sqlsrv

#### Root folder
/laravel

### How to run

#### Clone this repo
$ git clone https://github.com/antonioanerao/dockerfile-laravel.git

#### CD to the repo folder
$ cd dockerfile-laravel

#### Build the docker image
$ docker build -t laravel .

#### Do you prefer a Docker Image instead?
https://hub.docker.com/r/antonioanerao/laravel
39 changes: 39 additions & 0 deletions config_cntr/default.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
server {
# Porta WEB
listen 80 default_server;
listen 443;
#allow 10.80.15.200;
#deny 10.80.15.59;

#listen [::]:80 default_server;

# Nome do servidor
server_name _;

# Diretorio de Log
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
rewrite_log on;

# Diretorio dos arquivos web
root /laravel/public;

# Extensões de arquivos que serão lidos
index index.php index.html;

client_max_body_size 4096M;

# URL amigáveis
location / {
try_files $uri $uri/ /index.php?$query_string;
}
# Configurações PHP FPM.
location ~* \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_read_timeout 240;
fastcgi_index index.php;
fastcgi_split_path_info ^(.+\.php)(.*)$;
include /etc/nginx/fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
33 changes: 33 additions & 0 deletions config_cntr/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
user nginx;
worker_processes 1;

error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;


events {
worker_connections 1024;
}


http {
include /etc/nginx/mime.types;
default_type application/octet-stream;

log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';

access_log /var/log/nginx/access.log main;

sendfile on;
#tcp_nopush on;

keepalive_timeout 65;

#gzip on;

include /etc/nginx/conf.d/*.conf;
}

# daemon off;
Loading

0 comments on commit cd1f1b6

Please sign in to comment.