-
Notifications
You must be signed in to change notification settings - Fork 55
Add Egg Docs #177
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
Merged
+525
−0
Merged
Add Egg Docs #177
Changes from 8 commits
Commits
Show all changes
51 commits
Select commit
Hold shift + click to select a range
0e25381
Add 'Creating Eggs' category to sidebars
NerdsCorp cb11e23
Remove empty custom egg documentation file
NerdsCorp dce3fc4
Create creating-a-custom-docker-image.mdx
NerdsCorp b3c498c
Document custom egg creation process
NerdsCorp 1b6dc53
Import Admonition and Tabs components in documentation
NerdsCorp 630e837
Revise 'Creating a Custom Egg' documentation
NerdsCorp f1f1d9d
Add tutorial for creating a custom Docker image
NerdsCorp bcfbfab
Update creating-a-custom-egg.mdx
NerdsCorp 980ee05
Fix grammar and clarity in custom egg documentation
NerdsCorp 61a5572
Rename creating-a-custom-docker-image to creating-a-custom-yolk
NerdsCorp 7902bd2
Clarify Docker images section in custom egg guide
NerdsCorp c30ad47
Update sidebars.ts
NerdsCorp aebe50a
Remove Table of Contents from custom yolk tutorial
NerdsCorp a77326b
Update creating-a-custom-egg.mdx
NerdsCorp 4d54e41
Update server port references in custom egg docs
NerdsCorp d8bb4ec
Fix typos and enhance clarity in custom egg guide
NerdsCorp 019234d
Fix typos and enhance clarity in custom egg doc
NerdsCorp dec3695
Enhance Docker images section with Yolk Repo link
NerdsCorp 4a5752d
Fix capitalization and hyphenation in egg documentation
NerdsCorp 2a652dd
Change Docker base image to eclipse-temurin:8-jdk-noble
NerdsCorp d651331
Change Docker base image to alpine version
NerdsCorp 4ed41e0
Enable the dockerfile syntax highlighting
QuintenQVD0 c1bbaa4
Merge branch 'main' into main
QuintenQVD0 9f5a24f
It is docker not Dockerfile
QuintenQVD0 7fe6659
Document how to reference egg variables
NerdsCorp e3c15c9
Change Dockerfile base image and fix typos
NerdsCorp a9c1592
Update creating-a-custom-egg.mdx
NerdsCorp e98edd9
Fix hyphenation in steam_disk_space description
NerdsCorp ef73c00
Update creating-a-custom-yolk.mdx
NerdsCorp 9b4d6d5
Refine egg documentation for clarity and consistency
NerdsCorp 012651b
Enhance Dockerfile for multi-platform support-maybe this is better??
NerdsCorp 04aec64
Fix command from 'adduser' to 'useradd'
NerdsCorp cf132d5
Update explanation of useradd command in container setup
NerdsCorp b8a71ce
Change dependency installation from Alpine to Ubuntu
NerdsCorp 9c5897b
Change target OS examples in custom yolk guide
NerdsCorp 1399c89
Update WORKDIR and ENTRYPOINT instructions
NerdsCorp ca9d1f3
Fix typos in creating-a-custom-yolk.mdx
NerdsCorp f15c46d
Update creating-a-custom-yolk.mdx
NerdsCorp 037a1e2
Fix entrypoint.sh copy path in Dockerfile
QuintenQVD0 04a00ea
Revise egg documentation for clarity and updates
NerdsCorp 21f241d
Merge branch 'pelican-dev:main' into main
NerdsCorp 303ce95
Fix typos and improve clarity in documentation
NerdsCorp 0104b24
Fix placeholder names in custom egg documentation
NerdsCorp 66e564d
Refactor LABELs in creating-a-custom-yolk.mdx
NerdsCorp f59c67a
Update image description for Custom Yolk
NerdsCorp e5c5822
Update creating-a-custom-egg.mdx
NerdsCorp 2d0be70
Fix typo in target operating system example
NerdsCorp ed0e0ac
Simplify instructions for creating a custom egg
NerdsCorp 62c4a7a
Change variable syntax in custom egg documentation
NerdsCorp 1ea3c22
Fix COPY command path in Dockerfile example
NerdsCorp 4ff3b90
Update variable syntax note for clarity
NerdsCorp File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,141 @@ | ||
| import Admonition from '@theme/Admonition'; | ||
| import Tabs from '@theme/Tabs'; | ||
| import TabItem from '@theme/TabItem'; | ||
|
|
||
| # Creating a Custom Docker Image | ||
rmartinoscar marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| :::warning | ||
| This tutorial uses examples from our [`ghcr.io/pelican-eggs/yolks:java_8`](https://github.com/pelican-eggs/yolks) docker image, which can be found on GitHub. This tutorial also assumes some knowledge of [Docker](https://docker.io/), we suggest reading up if this all looks foreign to you. | ||
| ::: | ||
|
|
||
| ## Table of Contents | ||
|
|
||
| ## Creating the Dockerfile | ||
|
|
||
| The most important part of this process is to create the [`Dockerfile`](https://docs.docker.com/engine/reference/builder/) that will be used by Wings. Due to heavy restrictions on server containers, you must setup this file in a specific manner. | ||
|
|
||
| We try to make use of [Alpine Linux](https://alpinelinux.org) as much as possible for our images in order to keep their size down. | ||
|
|
||
| ```dockerfile | ||
| # ---------------------------------- | ||
| # Pelican Panel Dockerfile | ||
| # Environment: Java | ||
| # Minimum Panel Version: 1.0.0 | ||
| # ---------------------------------- | ||
| FROM openjdk:8-jdk-alpine | ||
|
|
||
| LABEL author="Pelican Panel" maintainer="support@pelican.dev" | ||
|
|
||
| RUN apk add --no-cache --update curl ca-certificates openssl git tar bash sqlite fontconfig \ | ||
| && adduser --disabled-password --home /home/container container | ||
|
|
||
| USER container | ||
| ENV USER=container HOME=/home/container | ||
|
|
||
| WORKDIR /home/container | ||
|
|
||
| COPY ./entrypoint.sh /entrypoint.sh | ||
|
|
||
| CMD ["/bin/bash", "/entrypoint.sh"] | ||
| ``` | ||
|
|
||
| Let's walk through the `Dockerfile` above. The first thing you'll notice is the [`FROM`](https://docs.docker.com/engine/reference/builder/#from) declaration. | ||
|
|
||
| ```dockerfile | ||
| FROM openjdk:8-jdk-alpine | ||
| ``` | ||
|
|
||
| In this case, we are using [`openjdk:8-jdk-alpine`](https://github.com/docker-library/openjdk) which provides us with Java 8. | ||
|
|
||
| ## Installing Dependencies | ||
|
|
||
| The next thing we do is install the dependencies we will need using Alpine's package manager: `apk`. You'll notice some specific flags that keep the container small, including `--no-cache`, as well as everything being contained in a single [`RUN`](https://docs.docker.com/engine/reference/builder/#run) block. | ||
|
|
||
| ## Creating a Container User | ||
|
|
||
| Within this `RUN` block, you'll notice the `adduser` command. | ||
|
|
||
| ```bash | ||
| adduser --disabled-password --home /home/container container | ||
| ``` | ||
|
|
||
| :::warning | ||
| All Pelican containers must have a user named `container`, and the user home **must** be `/home/container`. | ||
| ::: | ||
|
|
||
| After we create that user, we then define the default container [`USER`](https://docs.docker.com/engine/reference/builder/#user) as well as a few [`ENV`](https://docs.docker.com/engine/reference/builder/#env) settings to be applied to things running within the container. | ||
|
|
||
| ## Work Directory & Entrypoint | ||
|
|
||
| One of the last things we do is define a [`WORKDIR`](https://docs.docker.com/engine/reference/builder/#workdir) which is where everything else will be executed. The `WORKDIR` must be set to `/home/container`. | ||
|
|
||
| Finally, we need to copy our [`ENTRYPOINT`](https://docs.docker.com/engine/reference/builder/#entrypoint) script into the docker image root. This is done using [`COPY`](https://docs.docker.com/engine/reference/builder/#copy), after which we define the command to be used when the container is started using [`CMD`](https://docs.docker.com/engine/reference/builder/#cmd). The `CMD` line should always point to the `entrypoint.sh` file. | ||
|
|
||
| ```dockerfile | ||
| COPY ./entrypoint.sh /entrypoint.sh | ||
| CMD ["/bin/bash", "/entrypoint.sh"] | ||
| ``` | ||
|
|
||
| ## Entrypoint Script | ||
|
|
||
| In order to complete this `Dockerfile`, we will need an `entrypoint.sh` file which tells Docker how to run this specific server type. | ||
|
|
||
| These entrypoint files are actually fairly abstracted, and Wings will pass in the start command as an environment variable before processing it and then executing the command. | ||
|
|
||
| ```bash | ||
| #!/bin/bash | ||
| cd /home/container | ||
|
|
||
| # Output Current Java Version | ||
| java -version ## only really needed to show what version is being used. Should be changed for different applications | ||
|
|
||
| # Replace Startup Variables | ||
| MODIFIED_STARTUP=`eval echo $(echo ${STARTUP} | sed -e 's/{{/${/g' -e 's/}}/}/g')` | ||
| echo ":/home/container$ ${MODIFIED_STARTUP}" | ||
|
|
||
| # Run the Server | ||
| ${MODIFIED_STARTUP} | ||
| ``` | ||
|
|
||
| The second command, `cd /home/container`, simply ensures we are in the correct directory when running the rest of the commands. We then follow that up with `java -version` to output this information to end-users, but that is not necessary. | ||
|
|
||
| ## Modifying the Startup Command | ||
|
|
||
| The most significant part of this file is the `MODIFIED_STARTUP` environment variable. What we are doing in this case is parsing the environment `STARTUP` that is passed into the container by Wings. In most cases, this variable looks something like the example below: | ||
|
|
||
| ```bash | ||
| STARTUP="java -Xms128M -Xmx{{SERVER_MEMORY}}M -jar {{SERVER_JARFILE}}" | ||
| ``` | ||
|
|
||
| You'll notice some placeholders there, specifically `{{SERVER_MEMORY}}` and `{{SERVER_JARFILE}}`. These both refer to other environment variables being passed in, and they look something like the example below. | ||
|
|
||
| ```bash | ||
| SERVER_MEMORY=1024 | ||
| SERVER_JARFILE=server.jar | ||
| ``` | ||
|
|
||
| There are a host of different environment variables, and they change depending on the specific egg configuration. However, that is not necessarily anything to worry about here. | ||
|
|
||
| ```bash | ||
| MODIFIED_STARTUP=`eval echo $(echo ${STARTUP} | sed -e 's/{{/${/g' -e 's/}}/}/g')` | ||
| ``` | ||
|
|
||
| The command above simply evaluates the `STARTUP` environment variable, and then replaces anything surrounded in curly braces `{{EXAMPLE}}` with a matching environment variable (such as `EXAMPLE`). Thus, our `STARTUP` command: | ||
|
|
||
| ```bash | ||
| java -Xms128M -Xmx{{SERVER_MEMORY}}M -jar {{SERVER_JARFILE}} | ||
| ``` | ||
|
|
||
| Becomes: | ||
|
|
||
| ```bash | ||
| java -Xms128M -Xmx1024M -jar server.jar | ||
| ``` | ||
|
|
||
| ## Run the Command | ||
|
|
||
| The last step is to run this modified startup command, which is done with the line `${MODIFIED_STARTUP}`. | ||
|
|
||
| ## Note | ||
|
|
||
| Sometimes you may need to change the permissions of the `entrypoint.sh` file. On Linux you can do this by executing `chmod +x entrypoint.sh` in the directory where the file is located. | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.