-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
425f2e1
commit 39d0ac2
Showing
3 changed files
with
104 additions
and
22 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,60 @@ | ||
name: Create and publish a Docker image | ||
on: | ||
push: | ||
branches: ['main'] | ||
tags: | ||
- ".*" | ||
pull_request: | ||
paths: | ||
- Dockerfile | ||
- .github/workflows/docker.yml | ||
env: | ||
REGISTRY: ghcr.io | ||
IMAGE_NAME: ${{ github.repository }} | ||
jobs: | ||
build-and-push-image: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
packages: write | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Log in to the Container registry | ||
uses: docker/login-action@master | ||
with: | ||
registry: ${{ env.REGISTRY }} | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Extract metadata (tags, labels) for Docker | ||
id: meta-drafter | ||
uses: docker/metadata-action@master | ||
with: | ||
images: ${{ env.REGISTRY }}/${{ github.repository }}/drafter | ||
|
||
- name: Extract metadata (tags, labels) for Docker | ||
id: meta | ||
uses: docker/metadata-action@master | ||
with: | ||
images: ${{ env.REGISTRY }}/${{ github.repository }} | ||
|
||
- name: Build and push Docker image | ||
uses: docker/build-push-action@master | ||
with: | ||
context: . | ||
push: true | ||
tags: ${{ steps.meta-drafter.outputs.tags }} | ||
labels: ${{ steps.meta-drafter.outputs.labels }} | ||
target: drafter-build | ||
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ github.repository }}/drafter:latest | ||
|
||
- name: Build and push Docker image | ||
uses: docker/build-push-action@master | ||
with: | ||
context: . | ||
push: true | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
target: phpdraft |
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,23 +1,45 @@ | ||
FROM apiaryio/drafter:latest as drafter | ||
FROM composer:latest as composer | ||
|
||
FROM php:8.1-cli-alpine as build | ||
RUN apk add --no-cache \ | ||
$PHPIZE_DEPS \ | ||
openssl-dev | ||
RUN pecl install uopz \ | ||
&& docker-php-ext-enable uopz | ||
RUN echo "phar.readonly = 0" > "$PHP_INI_DIR/conf.d/phar.ini" | ||
COPY --from=composer /usr/bin/composer /usr/bin/composer | ||
COPY . /usr/src/phpdraft | ||
FROM debian:bullseye-slim AS drafter-build | ||
RUN apt-get update && \ | ||
apt-get install --yes curl ca-certificates | ||
|
||
RUN curl -L --fail -o drafter.tar.gz https://github.com/apiaryio/drafter/releases/download/v5.1.0/drafter-v5.1.0.tar.gz | ||
RUN install -d /usr/src/drafter | ||
RUN tar -xvf drafter.tar.gz --strip-components=1 --directory /usr/src/drafter | ||
|
||
WORKDIR /usr/src/drafter | ||
|
||
RUN apt-get install --yes cmake g++ | ||
|
||
RUN cmake -S . -B build -DCMAKE_BUILD_TYPE=Release | ||
RUN cmake --build build | ||
RUN cmake --install build | ||
|
||
CMD drafter | ||
|
||
FROM composer:latest AS composer | ||
|
||
WORKDIR /usr/src/phpdraft | ||
RUN /usr/bin/composer install | ||
RUN vendor/bin/phing phar-nightly | ||
COPY build/out/phpdraft-nightly.phar /usr/local/bin/phpdraft | ||
COPY . /usr/src/phpdraft/ | ||
RUN composer install --ignore-platform-req=ext-uopz | ||
|
||
FROM php:8.3-cli-bullseye AS phpdraft-build | ||
|
||
|
||
|
||
COPY --from=composer /usr/src/phpdraft /usr/src/phpdraft | ||
WORKDIR /usr/src/phpdraft | ||
|
||
RUN ./vendor/bin/phing phar-nightly | ||
COPY /usr/src/phpdraft/build/out/phpdraft-nightly.phar /usr/local/bin/phpdraft | ||
RUN chmod +x /usr/local/bin/phpdraft | ||
|
||
FROM php:8.3-cli-bullseye AS phpdraft | ||
|
||
FROM php:8.1-cli-alpine | ||
LABEL maintainer="Sean Molenaar [email protected]" | ||
RUN apk add --no-cache gcc | ||
COPY --from=drafter /usr/local/bin/drafter /usr/local/bin/drafter | ||
COPY --from=build /usr/local/bin/phpdraft /usr/local/bin/phpdraft | ||
ENTRYPOINT /usr/local/bin/phpdraft -f /tmp/drafter/full_test.apib | ||
|
||
COPY --from=phpdraft-build /usr/local/bin/phpdraft /usr/local/bin/phpdraft | ||
COPY --from=drafter-build /usr/local/bin/drafter /usr/local/bin/drafter | ||
|
||
RUN ls -al /usr/local/bin/phpdraft | ||
|
||
CMD phpdraft |
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