Skip to content
Open
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
11 changes: 11 additions & 0 deletions .github/workflows/3x.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,17 @@ jobs:
path: terminus.phar
if-no-files-found: error

build_docker_image:
runs-on: ubuntu-latest
name: Build Docker image
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Build Docker image
run: docker build . -t terminus
- name: Run built Docker image
run: docker run terminus art

Comment on lines +52 to +62
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be worth holding of on this until we have a public registry we can push to or until this repo has been onboarded to the WIF stuff so we can use the shared actions.

functional:
runs-on: ${{ matrix.operating-system }}
name: Functional testing matrix - PHP ${{ matrix.php-versions }} on ${{ matrix.operating-system }}
Expand Down
48 changes: 48 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# --- Composer Layer ---
FROM composer:2 AS composer

# --- Build Layer ---
FROM php:8.4-cli-alpine AS build

# Install dependencies for building PHAR
RUN apk add --no-cache bash git wget

# Install Composer
COPY --from=composer /usr/bin/composer /usr/bin/composer

WORKDIR /app

# Copy source files
COPY . .

# Install PHP dependencies
RUN composer install --no-interaction --no-dev --optimize-autoloader

# Install Box for PHAR building
RUN wget https://github.com/box-project/box/releases/download/4.6.7/box.phar -O /usr/local/bin/box && chmod +x /usr/local/bin/box

# Build PHAR file
RUN ./scripts/phar_build.sh

# --- Runtime Layer ---
FROM php:8.4-cli-alpine

# Install Git, Unzip, and Wget dependencies
RUN apk add --no-cache git openssh

# Create a non-root user and group
RUN addgroup -S terminus && adduser -S terminus -G terminus

# Switch to non-root user
USER terminus

WORKDIR /app

# Copy Composer from build layer
COPY --from=build /usr/bin/composer /usr/bin/composer

# Copy built PHAR from build layer
COPY --from=build /app/terminus.phar /app/terminus.phar

# Set entrypoint to run the PHAR
ENTRYPOINT ["/app/terminus.phar"]
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,28 @@ chmod +x terminus
./terminus self:update
sudo ln -s ~/terminus/terminus /usr/local/bin/terminus
```

### Standalone Docker container

Terminus can also be built and run as a Docker container, rather than relying on system version of PHP and other dependencies.

```bash
docker build . -t terminus
```

In order to store configuration and install plugins, Terminus requires a persistent data directory. If you only plan to run Terminus via Docker, please run the following command to create a Docker data volume:

```bash
docker volume create terminus --ignore
```

The container can be run of 2 different ways:

- Directly using `docker` (or `podman`, etc.):

docker run -tv terminus:/root/.terminus terminus:latest self:info

- Alternatively implement an alias in your local environment:

alias terminus="docker run -tv ~/.terminus:/root/.terminus terminus:latest"
terminus self:info