Skip to content

Commit

Permalink
Updated build.yml, Dockerfile, README.md, and added .editorconfig #7 (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
HussainTechSavvy authored Dec 21, 2023
1 parent 02b0b28 commit 62783e2
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 30 deletions.
20 changes: 20 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# EditorConfig is awesome: https://EditorConfig.org

# top-most EditorConfig file
root = true

[*]
indent_style = space
indent_size = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = false
insert_final_newline = true

[*.{yml,yaml}]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = false
insert_final_newline = true
47 changes: 26 additions & 21 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,34 @@ name: Build and Push Docker Image
on:
push:
branches:
- php82
- "8.2"

jobs:
build-and-push:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Get Short SHA
id: vars
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT

- name: Build and Push Docker Image
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: improwised/php-base:8.2-${{ steps.vars.outputs.sha_short }}
- name: Checkout code
uses: actions/checkout@v4
timeout-minutes: 5
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
timeout-minutes: 5
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ vars.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
timeout-minutes: 5
- name: Create Tag
id: tag
run: echo "tag=${{ github.ref_name }}-$(git rev-parse --short HEAD)-$(date +%s)" >> $GITHUB_OUTPUT
timeout-minutes: 5
- name: Build and Push Docker Image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: improwised/php-base:${{ steps.tag.outputs.tag }}
cache-from: type=gha
cache-to: type=gha,mode=max
timeout-minutes: 5
15 changes: 7 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
FROM alpine:3.18
MAINTAINER Rakshit Menpara <[email protected]>

ENV DOCKERIZE_VERSION v0.6.1
RUN wget https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-alpine-linux-amd64-$DOCKERIZE_VERSION.tar.gz \
Expand All @@ -10,11 +9,11 @@ RUN wget https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSI

# Install OS Dependencies
RUN set -ex \
&& apk add --no-cache --virtual .build-deps \
&& apk add --no-cache --virtual .build-deps \
autoconf automake build-base python3 gmp-dev \
curl \
tar \
&& apk add --no-cache --virtual .run-deps \
&& apk add --no-cache --virtual .run-deps \
nodejs npm \
# PHP and extensions
php82 php82-bcmath php82-ctype php82-curl php82-dom php82-exif php82-fileinfo \
Expand All @@ -29,21 +28,21 @@ RUN set -ex \
# Nginx
nginx \
# Create directories
&& mkdir -p /etc/nginx \
&& mkdir -p /etc/nginx \
&& mkdir -p /run/nginx \
&& mkdir -p /etc/nginx/sites-available \
&& mkdir -p /etc/nginx/sites-enabled \
&& mkdir -p /var/log/supervisor \
&& rm -Rf /var/www/* \
&& rm -Rf /etc/nginx/nginx.conf \
# Composer
&& wget https://composer.github.io/installer.sig -O - -q | tr -d '\n' > installer.sig \
# Composer
&& wget https://composer.github.io/installer.sig -O - -q | tr -d '\n' > installer.sig \
&& php82 -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" \
&& php82 -r "if (hash_file('SHA384', 'composer-setup.php') === file_get_contents('installer.sig')) { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" \
&& php82 composer-setup.php --install-dir=/usr/bin --filename=composer \
&& php82 -r "unlink('composer-setup.php'); unlink('installer.sig');" \
# Cleanup
&& apk del .build-deps
# Cleanup
&& apk del .build-deps

################## INSTALLATION ENDS ##################

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Base container image for modern PHP applications built on top of Alpine Linux. T
* Create a `Dockerfile` in root of your PHP project.

```dockerfile
FROM improwised/php-base:latest
FROM improwised/php-base:8.2-<sha256>-<epoch>

# Copy Composer
COPY ./composer.* /var/www/
Expand Down

0 comments on commit 62783e2

Please sign in to comment.