Skip to content

Commit

Permalink
chore: #30 pack server into a docker image
Browse files Browse the repository at this point in the history
Release-As: 0.0.1
  • Loading branch information
bohdan-shulha committed Jul 2, 2024
1 parent 6093084 commit 7b76ad1
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules/
vendor/
60 changes: 60 additions & 0 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
on:
push:
branches:
- main

permissions:
contents: write
packages: write
pull-requests: write
id-token: write

name: release-please

jobs:
release-please:
runs-on: ubuntu-latest
outputs:
release_created: ${{ steps.release.outputs.release_created }}
tag_name: ${{ steps.release.outputs.tag_name }}
steps:
- uses: googleapis/release-please-action@v4
id: release
with:
token: ${{ secrets.GITHUB_TOKEN }}
release-type: php
- run: echo "release_created=${{ steps.release.outputs.release_created }}" >> "$GITHUB_OUTPUT"
- run: echo "tag_name=${{ steps.release.outputs.tag_name }}" >> "$GITHUB_OUTPUT"

build-and-publish:
runs-on: ubuntu-latest
needs: release-please
if: ${{ needs.release-please.outputs.release_created }}
steps:
- name: Login to Docker Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v5
with:
push: true
tags: ghcr.io/ptah-sh/ptah-server:latest,ghcr.io/ptah-sh/ptah-server:${{ needs.release-please.outputs.tag_name }}
# TODO: should we create a github deployment?
deploy:
runs-on: ubuntu-latest
needs:
- release-please
- build-and-publish
if: ${{ needs.release-please.outputs.release_created }}
steps:
- name: Deploy
run: |
curl --fail-with-body -X POST \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'X-Ptah-Token: ${{ secrets.PTAH_TOKEN }}' \
-d '{"processes":[{"name":"svc","dockerImage":"ghcr.io/ptah-sh/ptah-server:${{ needs.release-please.outputs.tag_name }}"}]}' \
https://app.ptah.sh/api/v0/services/2/deploy
26 changes: 26 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
FROM bitnami/php-fpm:latest

RUN install_packages nodejs npm \
&& apt-get clean && rm -rf /var/lib/apt/lists /var/cache/apt/archives

WORKDIR /app

ENV COMPOSER_ALLOW_SUPERUSER=1

COPY package.json .
COPY package-lock.json .

RUN npm i --frozen-lockfile

COPY composer.json .
COPY composer.lock .

RUN composer install --no-scripts

COPY . .

RUN composer install

RUN npm run build \
&& apt-get -y remove npm \
&& apt-get -y autoremove \

0 comments on commit 7b76ad1

Please sign in to comment.