Skip to content

Commit ee21361

Browse files
committed
Create new Dockerfile to run Terminus in isolated environment
- Install base dependencies in Dockerfile - Add README instructions to utilize standalone Docker container method - Add notes on using Docker volume for config persistence
1 parent 5d0ea74 commit ee21361

File tree

2 files changed

+64
-0
lines changed

2 files changed

+64
-0
lines changed

Dockerfile

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# --- Build Layer ---
2+
FROM php:8.2-cli AS build
3+
4+
# Install dependencies for building PHAR
5+
RUN apt-get update && apt-get install -y git unzip wget && rm -rf /var/lib/apt/lists/*
6+
7+
# Install Composer
8+
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer
9+
10+
WORKDIR /app
11+
12+
# Copy source files
13+
COPY . .
14+
15+
# Install PHP dependencies
16+
RUN composer install --no-interaction --no-dev --optimize-autoloader
17+
18+
# Install Box for PHAR building
19+
RUN wget https://github.com/box-project/box/releases/download/4.5.1/box.phar -O /usr/local/bin/box && chmod +x /usr/local/bin/box
20+
21+
# Build PHAR file
22+
RUN ./scripts/phar_build.sh
23+
24+
# --- Runtime Layer ---
25+
FROM php:8.2-cli-alpine
26+
27+
WORKDIR /app
28+
29+
# Copy Git
30+
RUN apk add --no-cache git unzip wget
31+
32+
# Copy Composer from build layer
33+
COPY --from=build /usr/bin/composer /usr/bin/composer
34+
35+
# Copy built PHAR from build layer
36+
COPY --from=build /app/terminus.phar /app/terminus.phar
37+
38+
# Set entrypoint to run the PHAR
39+
ENTRYPOINT ["/app/terminus.phar"]

README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,28 @@ chmod +x terminus
7474
./terminus self:update
7575
sudo ln -s ~/terminus/terminus /usr/local/bin/terminus
7676
```
77+
78+
### Standalone Docker container
79+
80+
Terminus can also be built and run as a Docker container, rather than relying on system version of PHP and other dependencies.
81+
82+
```bash
83+
docker build . -f Dockerfile -t terminus
84+
```
85+
86+
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:
87+
88+
```bash
89+
docker volume create terminus --ignore
90+
```
91+
92+
The container can be run of 2 different ways:
93+
94+
- Directly using `docker` (or `podman`, etc.):
95+
96+
docker run -tv terminus:/root/.terminus terminus:latest art
97+
98+
- Alternatively implement an alias in your local environment:
99+
100+
alias terminus="docker run -tv ~/.terminus:/root/.terminus terminus:latest"
101+
terminus art

0 commit comments

Comments
 (0)