Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix tag on wrong commit, #254 create working Dockerfile + CI #257

Merged
merged 4 commits into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Continuous Integration - Website
on: ["push", "pull_request"]
on: push
permissions: write-all

jobs:
Expand Down
36 changes: 36 additions & 0 deletions .github/workflows/docker-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Docker CI

on:
push:
tags:
- '*'

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Docker Metadata
id: docker-metadata
uses: docker/metadata-action@v5
with:
images: ghcr.io/propromo-software/propromo
tags: |
type=ref,event=tag

- name: Build and push
uses: docker/build-push-action@v6
with:
push: true
file: Dockerfile.new
tags: ${{ steps.docker-metadata.outputs.tags }}
labels: ${{ steps.docker-metadata.outputs.labels }}
3 changes: 2 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,9 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
commit: ${{ github.event.workflow_run.head_commit.sha }}
tag: ${{ steps.generate_release_tag.outputs.next_release_tag }}
name: Release ${{ github.sha }}
name: Release ${{ github.event.workflow_run.head_commit.sha }}
body: Release for commit '${{ github.event.workflow_run.head_commit.message }}'
draft: false
prerelease: true
Expand Down
56 changes: 56 additions & 0 deletions Dockerfile.new
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Using the LTS version of Node.js ~45MB
FROM node:20.11.1-alpine3.18 AS install-and-build

# Environment variables
WORKDIR /app
ENV NODE_ENV=production

# Build assets (context needed, that is why we don't copy package.json and package-lock.json alone)
COPY . .
COPY .env.docker.example .env
RUN npm install --frozen-lockfile --production --include=dev
RUN npm run build --optimize

FROM trafex/php-nginx:3.4.0

# Install composer from the official image
COPY --from=composer /usr/bin/composer /usr/bin/composer

# USER nginx

WORKDIR /app

COPY --from=install-and-build --chown=nobody /app .

# Run composer install to install the dependencies - ignore-platform required to *actually* exclude dev deps
RUN composer install --optimize-autoloader --no-interaction --no-dev --ignore-platform-req=ext-simplexml

# Optimizing Configuration loading
RUN php artisan config:cache

# Optimizing Event loading
RUN php artisan event:cache

# Optimizing Route loading
RUN php artisan route:cache

# Optimizing View loading
RUN php artisan view:cache

RUN php artisan optimize

USER root
RUN chown -R nobody:nobody /var/www
USER nobody

RUN <<EOF
rm -rf /var/www/html
cp -r /app/public/ /var/www/html
ln -s /var/www/html /var/www/public
cp -r /app/bootstrap /var/www
cp -r /app/vendor /var/www
cp -r /app/app /var/www
cp -r /app/routes /var/www

ln -s /var/www/vendor/livewire/livewire/dist/ /var/www/html/livewire
EOF