generated from oci/template
it builds and it runs, needs further testing
All checks were successful
Build Docker Image on Commit / build-and-publish (push) Successful in 9s
All checks were successful
Build Docker Image on Commit / build-and-publish (push) Successful in 9s
This commit is contained in:
parent
1ef69c170f
commit
e6e946ce44
5 changed files with 93 additions and 35 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
/data
|
22
Dockerfile
22
Dockerfile
|
@ -8,7 +8,7 @@ RUN apt-get update && \
|
||||||
clang \
|
clang \
|
||||||
llvm \
|
llvm \
|
||||||
libclang-dev \
|
libclang-dev \
|
||||||
libssl-dev \
|
libssl-dev \
|
||||||
pkg-config \
|
pkg-config \
|
||||||
ca-certificates \
|
ca-certificates \
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
@ -32,9 +32,23 @@ FROM debian:bookworm-slim
|
||||||
RUN apt-get update && \
|
RUN apt-get update && \
|
||||||
apt-get install -y --no-install-recommends \
|
apt-get install -y --no-install-recommends \
|
||||||
ca-certificates \
|
ca-certificates \
|
||||||
|
gosu \
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
# Copy the compiled binary
|
# Create default non-root user
|
||||||
COPY --from=builder /src/freenet/target/release/freenet /usr/local/bin/freenet
|
RUN useradd -m -u 1000 -s /bin/bash freenetuser && \
|
||||||
|
mkdir -p /data && \
|
||||||
|
chown freenetuser:freenetuser /data
|
||||||
|
|
||||||
CMD ["freenet", "-b", "0.0.0.0"]
|
# Copy binary and entrypoint
|
||||||
|
COPY --from=builder /src/freenet/target/release/freenet /usr/local/bin/
|
||||||
|
COPY entrypoint.sh /entrypoint.sh
|
||||||
|
RUN chmod +x /entrypoint.sh
|
||||||
|
|
||||||
|
# Environment variables
|
||||||
|
ENV DATA_DIR="/data/data" \
|
||||||
|
CONFIG_DIR="/data/config"
|
||||||
|
|
||||||
|
VOLUME ["/data"]
|
||||||
|
ENTRYPOINT ["/entrypoint.sh"]
|
||||||
|
CMD ["freenet"]
|
44
Readme.md
44
Readme.md
|
@ -1,36 +1,18 @@
|
||||||
# README for Docker Image Build and Publish Workflows
|
# Freenet Core Docker Container
|
||||||
|
|
||||||
## Overview
|
Minimal Docker image for [Freenet Core](https://github.com/freenet/freenet-core).
|
||||||
|
|
||||||
This repository contains two GitHub Actions workflows that automate the building and publishing of Docker images to an OCI registry.
|
## Quick Start
|
||||||
|
|
||||||
### Workflows
|
Make sure to expose the ports you need for the service to work, I dont know which ones are needed as I just recently found out about Freenet
|
||||||
|
```bash
|
||||||
|
docker run -v freenet_data:/data git.merith.xyz/oci/freenet
|
||||||
|
```
|
||||||
|
|
||||||
1. **On Commit to Main**
|
## Features
|
||||||
- **Trigger:** Activates on commits to the `main` branch (tags are excluded).
|
- Root/non-root support (`RUN_AS=UID:GID`)
|
||||||
- **Purpose:** Builds and publishes a Docker image for each commit.
|
- Persistent `/data` volume
|
||||||
|
|
||||||
2. **On Tag Push**
|
## Configuration
|
||||||
- **Trigger:** Activates when a new tag is pushed.
|
- Data: `/data/{data,config}`
|
||||||
- **Purpose:** Builds and publishes a Docker image for the tag and tags it as `latest`.
|
- Custom args: Append to `docker run`
|
||||||
|
|
||||||
## Prerequisites
|
|
||||||
|
|
||||||
- **Secrets Needed:**
|
|
||||||
- `OCI_TOKEN`: Your OCI registry token.
|
|
||||||
- `OCI_USER`: Your OCI registry username.
|
|
||||||
|
|
||||||
## How to Use
|
|
||||||
|
|
||||||
1. **Clone the Repository:** Get a local copy of this repository.
|
|
||||||
2. **Modify Dockerfile:** Update the `Dockerfile` for your application.
|
|
||||||
3. **Push Changes:** Push changes to the `main` branch or create a new tag.
|
|
||||||
4. **Check Workflow Status:** View the Actions tab in Forgjo to monitor workflow runs.
|
|
||||||
|
|
||||||
## Notes
|
|
||||||
|
|
||||||
- Ensure your Docker environment is compatible with multi-platform builds if necessary.
|
|
||||||
|
|
||||||
## License
|
|
||||||
|
|
||||||
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
|
|
||||||
|
|
15
docker-compose.yml
Normal file
15
docker-compose.yml
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
|
||||||
|
services:
|
||||||
|
freenet:
|
||||||
|
# image: git.merith.xyz/oci/freenet:nightly
|
||||||
|
build: ./
|
||||||
|
container_name: freenet
|
||||||
|
ports:
|
||||||
|
# Opening all ports I see in the log, I dont know much about them
|
||||||
|
- "31337:31337"
|
||||||
|
- "40185:40185"
|
||||||
|
- "43841:43841"
|
||||||
|
- "50509:50509"
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
- ./data:/data
|
46
entrypoint.sh
Normal file
46
entrypoint.sh
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# Create data directories
|
||||||
|
mkdir -p "${DATA_DIR}" "${CONFIG_DIR}"
|
||||||
|
|
||||||
|
# Default command if none provided
|
||||||
|
DEFAULT_CMD="freenet"
|
||||||
|
CMD=${@:-$DEFAULT_CMD}
|
||||||
|
|
||||||
|
# Check if we're root
|
||||||
|
if [ "$(id -u)" = "0" ]; then
|
||||||
|
# If RUN_AS is set, run as that user
|
||||||
|
if [ -n "${RUN_AS}" ]; then
|
||||||
|
USER_ID=$(echo "${RUN_AS}" | cut -d: -f1)
|
||||||
|
GROUP_ID=$(echo "${RUN_AS}" | cut -d: -f2)
|
||||||
|
|
||||||
|
echo "Running as ${RUN_AS}"
|
||||||
|
echo "User ID: ${USER_ID}"
|
||||||
|
echo "Group ID: ${GROUP_ID}"
|
||||||
|
|
||||||
|
# Create user if it doesn't exist
|
||||||
|
if ! getent group "${GROUP_ID}" >/dev/null; then
|
||||||
|
groupadd -g "${GROUP_ID}" freenetuser
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! id "${USER_ID}" >/dev/null 2>&1; then
|
||||||
|
useradd -l -u "${USER_ID}" -g "${GROUP_ID}" freenetuser -d /home/freenetuser
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Fix permissions
|
||||||
|
chown -R "${USER_ID}:${GROUP_ID}" /data
|
||||||
|
export HOME="/home/freenetuser"
|
||||||
|
|
||||||
|
echo "Executing command: ${CMD}"
|
||||||
|
exec gosu "${USER_ID}:${GROUP_ID}" ${CMD}
|
||||||
|
else
|
||||||
|
# Run as root if no RUN_AS specified
|
||||||
|
echo "Executing as root: ${CMD}"
|
||||||
|
exec ${CMD}
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
# Already non-root
|
||||||
|
echo "Executing as $(id -u): ${CMD}"
|
||||||
|
exec ${CMD}
|
||||||
|
fi
|
Loading…
Reference in a new issue