Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ReallyFatYoshi committed Jun 8, 2024
0 parents commit 12ceda9
Show file tree
Hide file tree
Showing 7 changed files with 305 additions and 0 deletions.
66 changes: 66 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Create and publish Docker images

on:
push:
branches: ['release']

env:
REGISTRY: ghcr.io
IMAGE_NAME: debian

jobs:
build-and-push-images:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
attestations: write
id-token: write

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up jq
run: sudo apt-get update && sudo apt-get install -y jq

- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Extract version from build.json
id: extract_version
run: |
VERSION=$(jq -r '.latest' build.json)
echo "VERSION=${VERSION}" >> $GITHUB_ENV
- name: Adjust permissions for entrypoint
run: chmod +x images/entrypoint.sh

- name: Build and push Docker images
run: |
REPO_NAME=$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]')
IMAGE_TAG=${{ env.VERSION }}
echo "Building and pushing $IMAGE_NAME with tags $IMAGE_TAG and latest"
docker build -t ${{ env.REGISTRY }}/${REPO_NAME}:${IMAGE_TAG} -t ${{ env.REGISTRY }}/${REPO_NAME}:latest images/
docker push ${{ env.REGISTRY }}/${REPO_NAME}:${IMAGE_TAG}
docker push ${{ env.REGISTRY }}/${REPO_NAME}:latest
- name: Generate artifact attestations for Docker images
run: |
REPO_NAME=$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]')
IMAGE_TAG=${{ env.VERSION }}
echo "Generating attestation for $IMAGE_NAME"
IMAGE_DIGEST=$(docker inspect --format='{{index .RepoDigests 0}}' ${{ env.REGISTRY }}/${REPO_NAME}:${IMAGE_TAG})
echo "Image: ${{ env.REGISTRY }}/${REPO_NAME}:${IMAGE_TAG}" > attestation.txt
echo "Digest: ${IMAGE_DIGEST}" >> attestation.txt
gh actions upload-artifact --name $IMAGE_NAME-attestation --path attestation.txt
133 changes: 133 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# Snowpack dependency directory (https://snowpack.dev/)
web_modules/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional stylelint cache
.stylelintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variable files
.env
.env.development.local
.env.test.local
.env.production.local
.env.local

# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache

# Next.js build output
.next
out

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# vuepress v2.x temp and cache directory
.temp
.cache

# Docusaurus cache and generated files
.docusaurus

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port

# Stores VSCode versions used for testing VSCode extensions
.vscode-test

# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*

loc.docker-compose.yml
data
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 Serenity

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
35 changes: 35 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<br/>
<p align="center">
<a href="https://github.com/SerenityJS/docker">
<img src="https://raw.githubusercontent.com/SerenityJS/serenity/develop/public/serenityjs-banner.png" alt="Logo">
</a>
<p align="center">
<strong><font size = 5.5>SerenityJS Docker</font></strong>
<br/>
<br/>
<a href="https://github.com/SerenityJS/docker/issues">Report Bug</a>
<br/>
<br/>
<a href="https://discord.gg/jUcC3q59zg">
<img alt="discord" src="https://img.shields.io/discord/854092607239356457?style=for-the-badge&color=%237289DA&label=Discord&logo=discord&logoColor=white">
<a/>
<a href="https://github.com/SerenityJS/docker/blob/develop/LICENSE">
<img alt="License" src="https://img.shields.io/github/license/SerenityJS/docker?style=for-the-badge&label=Liscense&color=hotpink">
<a/>
<a href="https://www.npmjs.com/package/@serenityjs/launcher">
<img alt="License" src="https://img.shields.io/npm/v/@serenityjs/launcher?style=for-the-badge&label=NPM&logo=npm&logoColor=white">
<a/>
</p>
</p>

# SerenityJS Docker
Here's where you'll find Docker images for SerenityJS, set up for different Linux flavors. Perfect for running locally or in production!


## Quick Start
```sh
docker run ghcr.io/serenityjs/serenity-docker:latest -it --name serenityjs-docker -v data:/data -p 19132:19132
```

> [!NOTE]
> For any questions related to SerenityJS and our docker containers head to our [discord](https://discord.gg/jUcC3q59zg).
4 changes: 4 additions & 0 deletions build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"latest": "1.0.0",
"versions": []
}
29 changes: 29 additions & 0 deletions image/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
FROM debian:stable-slim

LABEL author="ReallyFatYoshi <github.com/ReallyFatYoshi>"
LABEL org.opencontainers.image.source="https://github.com/SerenityJS/docker"
LABEL org.opencontainers.image.description="SerenityJS docker image for debian."
LABEL org.opencontainers.image.licenses="MIT"

# Install necessary packages and clean up in one layer
RUN apt-get update && \
apt-get install -y wget nodejs npm && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

EXPOSE 19132/udp

WORKDIR /root

COPY entrypoint.sh .

# Download SerenityJS executable and make it executable
RUN wget -O serenityjs-linux "https://github.com/SerenityJS/executable/releases/latest/download/serenityjs-linux" && \
chmod +x serenityjs-linux

# Create /data directory and symbolic links
RUN mkdir /data && \
ln -s /data/server.properties /root/server.properties && \
ln -s /data/permissions.json /root/permissions.json

ENTRYPOINT ["/bin/bash", "-c", "/root/entrypoint.sh"]
17 changes: 17 additions & 0 deletions image/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

term_handler() {
timestamp=$(date "+%m-%d-%Y %H:%M:%S")
GRAY='\033[0;90m'
YELLOW='\033[0;33m'
NC='\033[0m'

echo -e "${GRAY}<${timestamp}> ${GRAY}[Serenity] ${GRAY}[${YELLOW}Warning${GRAY}] ${RED}SIGTERM received, exiting...${NC}"
exit 0
}

trap 'term_handler' SIGTERM

/root/serenityjs-linux &

wait $!

0 comments on commit 12ceda9

Please sign in to comment.