Skip to content

Commit 1a3609f

Browse files
authored
Merge pull request #23 from azapater/main
New run.sh, README.md and dockerfile optimizations
2 parents a3059b3 + cbb8b46 commit 1a3609f

11 files changed

+381
-80
lines changed

.github/images/embt-logo-black.png

19.4 KB
Loading

.github/images/embt-logo-white.png

17.8 KB
Loading

.github/images/rad-studio-logo.png

42.7 KB
Loading

Dockerfile

+41-23
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,57 @@
1-
FROM ubuntu:jammy
2-
# jammy is the code name of 22.04 LTS
1+
# Build Stage
2+
FROM ubuntu:jammy as builder
33

4-
ARG password=embtdocker
4+
ARG password=securepass
55

66
ENV PA_SERVER_PASSWORD=$password
7+
ENV PA_SERVER_URL=https://altd.embarcadero.com/releases/studio/23.0/121/1211/LinuxPAServer23.0.tar.gz
8+
ENV PA_SERVER_VERSION=23.0
9+
10+
# Install build dependencies
11+
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -yy --no-install-recommends \
12+
curl \
13+
&& rm -rf /var/lib/apt/lists/*
14+
15+
# Download and extract PAServer
16+
RUN curl -L "${PA_SERVER_URL}" -k -o ./paserver.tar.gz \
17+
&& tar xvzf paserver.tar.gz \
18+
&& mkdir /paserver \
19+
&& mv PAServer-${PA_SERVER_VERSION}/* /paserver \
20+
&& rm -rf PAServer-${PA_SERVER_VERSION} paserver.tar.gz
21+
22+
# Runtime Stage
23+
FROM ubuntu:jammy
724

8-
RUN apt-get update && \
9-
DEBIAN_FRONTEND=noninteractive apt-get -yy install \
25+
# Install runtime dependencies
26+
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -yy --no-install-recommends \
1027
joe \
11-
wget \
12-
p7zip-full \
1328
curl \
14-
openssh-server \
1529
build-essential \
30+
p7zip-full \
31+
openssh-server \
1632
zlib1g-dev \
1733
libcurl4-gnutls-dev \
1834
libncurses5 \
19-
libpython3.10
20-
21-
### Install PAServer
22-
ADD https://altd.embarcadero.com/releases/studio/23.0/121/1211/LinuxPAServer23.0.tar.gz ./paserver.tar.gz
35+
libpython3.10 \
36+
&& rm -rf /var/lib/apt/lists/*
2337

24-
RUN tar xvzf paserver.tar.gz
25-
RUN mv PAServer-23.0/* .
26-
RUN rm PAServer-23.0 -r
27-
RUN rm paserver.tar.gz
38+
# Copy PAServer and the runner script from the builder stage
39+
COPY --from=builder /paserver /paserver
40+
COPY paserver_docker.sh /paserver/paserver_docker.sh
2841

29-
# link to installed libpython3.10
30-
RUN mv lldb/lib/libpython3.so lldb/lib/libpython3.so_
31-
RUN ln -s /lib/x86_64-linux-gnu/libpython3.10.so.1 lldb/lib/libpython3.so
42+
# Set work directory
43+
WORKDIR /paserver
3244

33-
COPY paserver_docker.sh ./paserver_docker.sh
34-
RUN chmod +x paserver_docker.sh
45+
# Creates the symlink to the Python interpreter in the PAServer required location and grant execution permission to the runner script
46+
RUN mv lldb/lib/libpython3.so lldb/lib/libpython3.so_ \
47+
&& ln -s /lib/x86_64-linux-gnu/libpython3.10.so.1 lldb/lib/libpython3.so \
48+
&& chmod +x ./paserver_docker.sh
3549

36-
# PAServer
50+
# Expose PAServer's default port
3751
EXPOSE 64211
3852

39-
CMD ./paserver_docker.sh
53+
# Get ready to bind to PAServer's default scratch dir
54+
VOLUME ["/root/PAServer/scratch-dir"]
55+
56+
# Executes PAServer runner script
57+
ENTRYPOINT ["./paserver_docker.sh"]

README.md

+229-24
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,253 @@
1-
# paserver-docker
2-
<a href="https://www.embarcadero.com/products/rad-studio"><img alt="Embarcadero RAD Studio" src="https://user-images.githubusercontent.com/821930/228646830-41d2a8bf-e528-4e8d-ba55-51071d523087.png" align="right"></a>
3-
Docker script for RAD Studio Linux deployment via PAServer
1+
# RAD Studio PAServer Docker
42

5-
- **Container available on [Docker Hub](https://hub.docker.com/r/radstudio/pa-radserver)**
6-
- [PAServer Documentation](http://docwiki.embarcadero.com/RADStudio/en/PAServer,_the_Platform_Assistant_Server_Application)
7-
- [More information on RAD Studio](https://www.embarcadero.com/products/rad-studio)
8-
- Other containers: [InterBase](https://github.com/Embarcadero/InterBase-Docker) only, [RAD Server](https://github.com/Embarcadero/pa-radserver-docker), and [RAD Server with InterBase](https://github.com/Embarcadero/pa-radserver-ib-docker)
3+
<a href="https://www.embarcadero.com/products/rad-studio"><img alt="Embarcadero RAD Studio" src="https://raw.githubusercontent.com/azapater/paserver-docker/main/.github/images/rad-studio-logo.png" align="right"></a>
4+
5+
Welcome to the guide for deploying RAD Studio applications on Linux using Docker and PAServer. This repository offers a Docker script designed to simplify the setup and management of your development environment, allowing RAD Studio developers to deploy and test their applications in a Linux environment.
6+
7+
- **Container available on [Docker Hub][dockerhub-paserver]**
8+
- [PAServer Documentation][paserver-docs]
9+
- [More information on RAD Studio][radstudio]
10+
- Other containers: [InterBase][github-interbase-docker] only, [RAD Server][github-radserver-docker], and [RAD Server with InterBase][github-radserver-interbase-docker]
911

1012
The image defaults to running **PAServer** on port `64211` with the _password_ `securepass`
1113

12-
The 10.x images use Ubuntu 18.04.6 LTS (Bionic Beaver) while the 11.x images use Ubuntu 22.04.1 LTS (Jammy Jellyfish)
14+
The 10.x images use Ubuntu 18.04.6 LTS (Bionic Beaver) while the +11.x images use Ubuntu 22.04.1 LTS (Jammy Jellyfish)
15+
16+
## 🚀 How to Use [`run.sh`] Script
17+
18+
The [`run.sh`] script is your go-to automation tool for setting up and deploying the PAServer application with ease and flexibility. Below are the instructions to utilize this script effectively.
19+
20+
### 📋 Prerequisites
21+
22+
Ensure Docker is installed on your system as this script uses Docker for running the PAServer application.
23+
24+
### 🌟 Features
25+
26+
- **Customizable Name**: Assign a unique name to your PAServer container.
27+
- **Bind Path**: Designate a custom path for volume mapping.
28+
- **Detach Mode**: Opt for running your container in the background.
29+
- **Port Configuration**: Select the port where PAServer runs.
30+
- **Production Mode**: Activate production mode for your deployment.
31+
- **Version Control**: Choose the specific PAServer version for deployment.
32+
- **Password Protection**: Secure your PAServer with a custom password.
33+
34+
### 🛠️ Usage
35+
36+
Navigate to the directory containing [`run.sh`] in your terminal. Execute the script with your preferred options:
37+
38+
```bash
39+
./run.sh [OPTIONS]
40+
```
41+
42+
#### 📌 Options
43+
44+
- `--name` or `-n`: Container's name (e.g., `--name=myPAServer`).
45+
- `--path` or `-pa`: Bind path for volume mapping (e.g., `--path=/my/custom/path`).
46+
- `--detach` or `-d`: Run container in detach mode (background).
47+
- `--port` or `-p`: Port for PAServer (e.g., `--port=64211`).
48+
- `--production` or `-pr`: Enable production mode (`true`).
49+
- `--version` or `-v`: PAServer version (e.g., `--version=latest`).
50+
- `--password` or `-pw`: Set a password for PAServer (e.g., `--password=securepass`).
51+
- `--help` or `-h`: Shows the help of the script.
52+
53+
### 🌈 Examples
54+
55+
Run PAServer in production mode on port 65000 with a custom name and password:
56+
57+
```bash
58+
./run.sh --name=myPAServer --port=65000 --production --password=mysupersecurepassword
59+
```
60+
61+
Run PAServer in detach mode with a specific version, bind path, and password:
1362

14-
## Instructions
63+
```bash
64+
./run.sh --detach --version=12.1 --path=/my/custom/path --password=mysupersecurepassword
65+
```
66+
67+
### 📝 Note
68+
69+
Make sure you have the necessary permissions to execute `run.sh`. Use `chmod +x run.sh` to make it executable if needed.
70+
71+
## 🐳 Using `docker run` Directly
72+
73+
For users who prefer a more hands-on approach or wish to customize their deployment further, you can directly use the `docker run` command to start your PAServer container. This method provides flexibility and allows you to manually specify each option.
1574

16-
If you want to modify or build from GitHub without using [Docker Hub](https://hub.docker.com/r/radstudio/pa-radserver), you can build the Dockerfile with the `build.sh` script. **Note:** The Dockerfile requires the `paserver_docker.sh` script in the same directory
75+
### 🛠️ Command Structure
76+
77+
The basic structure of the command to run the PAServer Docker container is as follows:
78+
79+
```bash
80+
docker run [OPTIONS] radstudio/paserver:[VERSION]
1781
```
18-
./build.sh
82+
83+
### 📌 Options
84+
85+
- `-e PA_SERVER_PASSWORD=[PASSWORD]`: Sets the password for the PAServer. Replace `[PASSWORD]` with your desired password.
86+
- `--name [NAME]`: Assigns a custom name to your Docker container. Replace `[NAME]` with your preferred container name.
87+
- `-p [PORT]:64211`: Maps a custom port on your host to the PAServer's default port (64211). Replace `[PORT]` with the port number you wish to use.
88+
- `[DETACH_ARG]`: Use `-d` to run the container in detached mode (in the background).
89+
- `[BIND_PATH_ARG]`: Use `-v [HOST_PATH]:[CONTAINER_PATH]` to bind a volume for persistent data or configurations. Replace `[HOST_PATH]` and `[CONTAINER_PATH]` with your specific paths.
90+
91+
### 🌈 Examples
92+
93+
To run the PAServer in a Docker container named `myPAServer`, listening on port 65000, with a password of `mysupersecurepassword`, and running in detached mode, you would use the following command:
94+
95+
```bash
96+
docker run -d \
97+
-e PA_SERVER_PASSWORD=mysupersecurepassword \
98+
--name myPAServer \
99+
-p 65000:64211 radstudio/paserver:latest
100+
```
101+
102+
If you wish to bind a volume for persistent data, you can add the `-v` option:
103+
104+
```bash
105+
docker run -d \
106+
-e PA_SERVER_PASSWORD=securepass \
107+
-v /path/on/host:/root/PAServer/scratch-dir \
108+
--name myPAServer \
109+
-p 65000:64211 radstudio/paserver:latest
110+
```
111+
112+
#### Using Docker Compose
113+
114+
Docker Compose allows you to define and run multi-container Docker applications. Here is an example `docker-compose.yml` file that demonstrates how to use a Docker image as part of a service, utilizing environment variables for configuration.
115+
116+
```yaml
117+
version: '3.8'
118+
services:
119+
myPAServer:
120+
image: radstudio/paserver:latest
121+
container_name: myPAServer
122+
environment:
123+
- PA_SERVER_PASSWORD=${PA_SERVER_PASSWORD} # Environment variable for the server password
124+
ports:
125+
- '${HOST_PORT}:64211' # Environment variable for the host port
126+
volumes:
127+
- ${HOST_PATH}:/root/PAServer/scratch-dir # Environment variable for the host path
128+
restart: unless-stopped
19129
```
20130
21-
To pull and run the [Docker Hub](https://hub.docker.com/r/radstudio/paserver) version of PAServer Docker for a debug/non-production environment use the `pull-run.sh` script
131+
This configuration defines a single service called `myPAServer`. It uses the Docker image `radstudio/paserver:latest`. The service configuration includes mapping a port from the host to the container, setting an environment variable for the server password, and mounting a volume from the host to the container. These settings are customizable through environment variables defined in a `.env` file located in the same directory as your `docker-compose.yml`.
132+
22133
```
23-
./pull-run.sh
134+
# .env file
135+
PA_SERVER_PASSWORD=securepass
136+
HOST_PORT=65000
137+
HOST_PATH=/path/on/host
24138
```
25139
26-
To pull and run the Docker Hub version of PAServer Docker for a non-debug/production environment use the `pull-run-production.sh` script
140+
To start your application, execute the following command in the directory containing your `docker-compose.yml`:
141+
142+
```bash
143+
docker-compose up
27144
```
28-
./pull-run-production.sh securepass123
145+
146+
This command initiates the Docker Compose process, which reads the `docker-compose.yml` file and the `.env` file, applying the configurations to start your service as defined.
147+
148+
This will pull the necessary image (if it's not already locally available), create the defined volumes, set the environment variables, and start your application on the specified ports.
149+
150+
#### 📝 Note
151+
152+
Ensure you replace `/path/on/host` with the actual path you wish to use for volume binding. The `latest` tag can be replaced with any specific version of the PAServer you wish to deploy.
153+
154+
## 🛠️ Customizing Your Docker Image
155+
156+
This guide will help you customize the PAServer image to suit your specific needs, such as adding additional files or folders, installing extra packages, and making other modifications.
157+
158+
### 📁 Adding Files or Folders
159+
160+
To add files or folders to your Docker image, use the `COPY` or `ADD` instruction in your Dockerfile. `COPY` is preferred for copying local files, while `ADD` can handle remote URLs and tar extraction.
161+
162+
#### Example: Adding a Configuration File
163+
164+
```dockerfile
165+
COPY ./myconfig.conf /etc/myapp/myconfig.conf
29166
```
30167

31-
To run the Docker Hub version of PAServer Docker for a debug/non-production environment use the `run.sh` script
168+
This command copies `myconfig.conf` from your project directory to `/etc/myapp/myconfig.conf` inside the Docker image.
169+
170+
### 📦 Installing Extra Packages
171+
172+
To install additional packages, you can modify the `RUN` command that installs packages. It's best to combine package installation commands into a single `RUN` instruction to reduce the number of layers in your Docker image.
173+
174+
#### Example: Installing Git and Cmake
175+
176+
```dockerfile
177+
RUN apt-get update && apt-get install -y \
178+
git \
179+
cmake \
180+
&& rm -rf /var/lib/apt/lists/*
181+
```
182+
183+
Based on each project, specific libraries may be necessary. This command updates the package lists, installs _Git_ and _Cmake_, and cleans up afterward to keep the image size down.
184+
185+
To avoid extra layering in the final Docker image, it's good practice to modify the existing `RUN apt-get update` command to include your required libraries.
186+
187+
### 🛠️ Customizing Installation Commands
188+
189+
You can customize the Dockerfile to change environment variables, download different versions of software, or modify the installation process.
190+
191+
#### Example: Setting a Custom Environment Variable
192+
193+
```dockerfile
194+
ENV MY_CUSTOM_VAR=myvalue
32195
```
33-
./run.sh
196+
197+
This sets an environment variable `MY_CUSTOM_VAR` that can be used by your application.
198+
199+
### 🏗️ Building Your Custom Image
200+
201+
After customizing your Dockerfile, you can build your Docker image using the `docker build` command.
202+
203+
```bash
204+
docker build -t my-custom-paserver:latest .
34205
```
35206

36-
To run the Docker Hub version of paserver docker for a non-debug/production environment use the `run-production.sh` script
207+
This command builds a Docker image named `my-custom-paserver` with the `latest` tag, using the Dockerfile in the current directory.
208+
209+
### 🔑 Using Build Arguments
210+
211+
For values that might change between builds (like passwords or version numbers), you can use `ARG` instructions in your Dockerfile and pass values with the `--build-arg` option during the build.
212+
213+
#### Example: Specifying a Custom Password
214+
215+
```dockerfile
216+
ARG password=securepass
37217
```
38-
./run-production.sh securepass123
218+
219+
Build with a custom password:
220+
221+
```bash
222+
docker build --build-arg password=mypassword -t my-custom-paserver:latest .
39223
```
40224

41-
---
225+
### 💡 Tips
226+
227+
- This repository provides a [`build.sh`] script that can be used as a template for simplifying custom builds.
228+
- Currently, this image is only compatible with `linux/amd64`. To avoid potential problems in arm setups, build the image with the arg `--platform linux/amd64`
229+
230+
### 🛡️ Best Practices
231+
232+
- **Minimize Layers**: Combine related commands into single `RUN` instructions where possible.
233+
- **Clean Up**: Remove unnecessary files and packages to keep the image size down.
234+
- **Use `.dockerignore`**: Add a `.dockerignore` file to your project to avoid copying unnecessary files into your Docker image.
235+
- **Secure Secrets**: Avoid hardcoding sensitive information in your Dockerfile. Use build arguments for build-time secrets and environment variables or Docker secrets for runtime secrets.
236+
237+
## License and Copyright
238+
239+
This software is Copyright &copy; 2024 by [Embarcadero Technologies, Inc.][embarcadero]
42240

43-
This software is Copyright &copy; 2023 by [Embarcadero Technologies, Inc.](https://www.embarcadero.com/)
241+
_You may only use this software if you are an authorized licensee of an Embarcadero developer tools product. See the latest [software license agreement][embarcadero-license] for any updates._
44242

45-
_You may only use this software if you are an authorized licensee of an Embarcadero developer tools product. See the latest [software license agreement](https://www.embarcadero.com/products/rad-studio/rad-studio-eula) for any updates._
243+
![Embarcadero(Black)](https://raw.githubusercontent.com/azapater/paserver-docker/main/.github/images/embt-logo-black.png#gh-light-mode-only)
244+
![Embarcadero(White)](https://raw.githubusercontent.com/azapater/paserver-docker/main/.github/images/embt-logo-white.png#gh-dark-mode-only)
46245

47-
![Embarcadero(Black-100px)](https://user-images.githubusercontent.com/821930/211648635-c0db6930-120c-4456-a7ea-dc7612f01451.png#gh-light-mode-only)
48-
![Embarcadero(White-100px)](https://user-images.githubusercontent.com/821930/211649057-7f1f1f07-a79f-44d4-8fc1-87c819386ec6.png#gh-dark-mode-only)
246+
[dockerhub-paserver]: https://hub.docker.com/r/radstudio/paserver
247+
[radstudio]: https://www.embarcadero.com/products/rad-studio
248+
[paserver-docs]: http://docwiki.embarcadero.com/RADStudio/en/PAServer,_the_Platform_Assistant_Server_Application
249+
[github-interbase-docker]: https://github.com/Embarcadero/InterBase-Docker
250+
[github-radserver-docker]: https://github.com/Embarcadero/pa-radserver-docker
251+
[github-radserver-interbase-docker]: https://github.com/Embarcadero/pa-radserver-ib-docker
252+
[embarcadero]: https://www.embarcadero.com/
253+
[embarcadero-license]: https://www.embarcadero.com/products/rad-studio/rad-studio-eula

build.sh

100644100755
+20-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,24 @@
1-
#!/bin/bash
1+
#!/usr/bin/env bash
22

3+
# Exit script on error
4+
set -e
5+
6+
# Variables for image name and tags
7+
IMAGE_NAME="radstudio/paserver"
8+
TAG_LATEST="latest"
9+
TAG_VERSION="athens"
10+
TAG_NUMERIC="12.1.1"
11+
12+
# Build the Docker image with the first tag
313
docker build . \
414
--build-arg password=securepass \
515
--platform linux/amd64 \
6-
--tag=radstudio/paserver:latest \
7-
--tag=radstudio/paserver:athens \
8-
--tag=radstudio/paserver:12.1.1 \
16+
--pull \
17+
-t ${IMAGE_NAME}:${TAG_LATEST} \
18+
19+
# Tag the built image with additional version tags
20+
docker tag "${IMAGE_NAME}:${TAG_LATEST}" "${IMAGE_NAME}:${TAG_VERSION}"
21+
docker tag "${IMAGE_NAME}:${TAG_LATEST}" "${IMAGE_NAME}:${TAG_NUMERIC}"
22+
23+
# Echo a success message
24+
echo "Docker image ${IMAGE_NAME} tagged with ${TAG_LATEST}, ${TAG_VERSION}, and ${TAG_NUMERIC}"

paserver_docker.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/bash
1+
#!/usr/bin/env bash
22

33
./paserver -password=$PA_SERVER_PASSWORD
44
status=$?

0 commit comments

Comments
 (0)