Skip to content

A lightweight Laravel Gitlab CI docker image based on Alpine

License

Notifications You must be signed in to change notification settings

ahmadabd/gitlab-ci

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Laravel Gitlab-CI

GitHub Docker Image Size (tag) Docker Pulls Docker Image Version (latest semver) Docker Cloud Automated build Docker Cloud Build Status

About

A Dockerfile for building an image for your Laravel app Gitlab CI/CD pipelines.

Table of Contents

Folder Structure

Although folder structure is self-explanatory, description is as below:

.
├── Dockerfile
├── LICENSE
├── readme.md
├── scripts
│   ├── cleanup.sh            # Removes build dependencies for lighter image size.
│   ├── install-node-yarn.sh  # Install your global npm/yarn packages here.
│   ├── install-packages.sh   # OS packages will be installed by this file.
│   └── install-php.sh        # PHP extensions and installation.
└── tests
    └── goss.yaml             # See "testing" section

Packages and Services

We created the Dockerfile with image size in mind, only packages and PHP extensions which are absolutely necessary are installed.

Service Version Argument
PHP 8.2.0 PHP_VERSION
Composer 2.2.5 COMPOSER_VERSION
Node 21.0.0 NODE_VERSION
NPM 10.2.0 NPM_VERSION
Yarn latest N/A
reg latest N/A
cfcli latest N/A
local-php-security-checker latest N/A

Customizing build versions

As you can see in the table above, some services have an argument in Dockerfile for you to modify the installation version. To do so, you need to clone the repo and build the image yourself:

git clone https://github.com/laramatics/gitlab-ci.git
cd gitlab-ci
# Modify files...
docker build \
  --build-arg NPM_VERSION=9.2.0 \
  --build-arg PHP_VERSION=8.2.0 \
  -t <image_name> .

Adding more PHP extensions

If you want to add more extensions to the PHP installation, you will have to build your own image based on the one already built or modify the Dockerfile and scripts/* to your liking and build your own image from it.

See Docker PHP Extension Installer for available extensions, alternatively you can install them fom source.

FROM laramatics/gitlab-ci:latest
# Add your extentions here...
RUN docker-php-ext-install -j "$(nproc)" <package_name>

Adding more packages

Sometimes you need a specific package for your pipeline; as described in the previous section, you can build your own image from laramatics/gitlab-ci or clone this repo and modify files to suit your needs.

git clone https://github.com/laramatics/gitlab-ci.git
cd gitlab-ci
# Modify files...
docker build -t <image_name> .

Testing

Tests are written using GOSS, to test your changes after modifying source files and building your own image, run:

GOSS_FILES_PATH=tests dgoss run -it <image_name>

References

About

A lightweight Laravel Gitlab CI docker image based on Alpine

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Shell 76.5%
  • Dockerfile 23.5%