Replace Travis with GHA

This commit is contained in:
Eric Nemchik
2020-10-25 15:37:31 -05:00
parent 4c97501561
commit de703301b8
3 changed files with 64 additions and 80 deletions
+28
View File
@@ -0,0 +1,28 @@
name: Build Image
on: [push, pull_request, workflow_dispatch]
jobs:
build:
env:
DOCKERHUB: "user/endpoint"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2.3.3
- name: Build image
id: build
run: |
docker build --no-cache -t ${DOCKERHUB}:${{ github.sha }} .
- name: Push image
if: ${{ github.ref == format('refs/heads/{0}-{1}', env.BASEIMAGE, env.MODNAME) }}
run: |
# Tag image
docker tag ${DOCKERHUB}:${{ github.sha }} ${DOCKERHUB}:latest
# Login to DockerHub
echo ${{ secrets.DOCKERPASS }} | docker login -u ${{ secrets.DOCKERUSER }} --password-stdin
# Push all of the tags
docker push ${DOCKERHUB}:${{ github.sha }}
docker push ${DOCKERHUB}:latest
-28
View File
@@ -1,28 +0,0 @@
os: linux
language: shell
branches:
only:
- my-branch #set this to your main git branch
services:
- docker
env:
global:
- DOCKERHUB="user/endpoint"
jobs:
include:
- stage: BuildImage
if: (NOT (type IN (pull_request)))
script:
# Build image
- docker build --no-cache -t ${DOCKERHUB}:${TRAVIS_COMMIT} .
- docker tag ${DOCKERHUB}:${TRAVIS_COMMIT} ${DOCKERHUB}:latest
# Login to DockerHub
- echo $DOCKERPASS | docker login -u $DOCKERUSER --password-stdin
# Push all of the tags
- docker push ${DOCKERHUB}:${TRAVIS_COMMIT}
- docker push ${DOCKERHUB}:latest
+20 -36
View File
@@ -17,7 +17,7 @@ Again, when pulling in logic from external sources practice caution and trust th
We host and publish official Mods at the [linuxserver/mods](https://hub.docker.com/r/linuxserver/mods/tags) endpoint as separate tags. Each tag is in the format of `<imagename>-<modname>` for the latest versions, and `<imagename>-<modname>-<commitsha>` for the specific versions. We host and publish official Mods at the [linuxserver/mods](https://hub.docker.com/r/linuxserver/mods/tags) endpoint as separate tags. Each tag is in the format of `<imagename>-<modname>` for the latest versions, and `<imagename>-<modname>-<commitsha>` for the specific versions.
Here's a list of the official Mods we host: https://github.com/linuxserver/docker-mods/blob/master/mod-list.yml Here's a list of the official Mods we host: <https://github.com/linuxserver/docker-mods/blob/master/mod-list.yml>
## Using a Docker Mod ## Using a Docker Mod
@@ -30,7 +30,7 @@ Consumption of a Docker Mod is intended to be as user friendly as possible and c
Full example: Full example:
``` ```bash
docker create \ docker create \
--name=nzbget \ --name=nzbget \
-e DOCKER_MODS=taisun/nzbget-mod:latest \ -e DOCKER_MODS=taisun/nzbget-mod:latest \
@@ -46,14 +46,14 @@ docker create \
This will spinup an nzbget container and apply the custom logic found in the following repository: This will spinup an nzbget container and apply the custom logic found in the following repository:
https://github.com/Taisun-Docker/Linuxserver-Mod-Demo <https://github.com/Taisun-Docker/Linuxserver-Mod-Demo>
This basic demo installs Pip and a couple dependencies for plugins some users leverage with nzbget. This basic demo installs Pip and a couple dependencies for plugins some users leverage with nzbget.
## Creating and maintaining a Docker Mod ## Creating and maintaining a Docker Mod
We will always recommend to our users consuming Mods that they leverage ones from active community members or projects so transparency is key here. We understand that image layers can be pushed on the back end behind these pipelines, but every little bit helps. We will always recommend to our users consuming Mods that they leverage ones from active community members or projects so transparency is key here. We understand that image layers can be pushed on the back end behind these pipelines, but every little bit helps.
In this repository we will be going over two basic methods of making a Mod along with an example of the Travis-CI.org build logic to get this into a Dockerhub endpoint. Though we are not officially endorsing Travis-CI here it is one of the most popular Open Source free build pipelines and only requires a Github account to get started. If you prefer others feel free to use them as long as build jobs are transparent. In this repository we will be going over two basic methods of making a Mod along with an example of the GitHub Actions build logic to get this into a Dockerhub endpoint. Though we are not officially endorsing GitHub Actions here it is built in to GitHub repositories and forks making it very easy to get started. If you prefer others feel free to use them as long as build jobs are transparent.
One of the core ideas to remember when creating a Mod is that it can only contain a single image layer, the examples below will show you how to add files standardly and how to run complex logic to assemble the files in a build layer to copy them over into this single layer. One of the core ideas to remember when creating a Mod is that it can only contain a single image layer, the examples below will show you how to add files standardly and how to run complex logic to assemble the files in a build layer to copy them over into this single layer.
@@ -61,7 +61,7 @@ One of the core ideas to remember when creating a Mod is that it can only contai
In this repository you will find the `Dockerfile` containing: In this repository you will find the `Dockerfile` containing:
``` ```Dockerfile
FROM scratch FROM scratch
# copy local files # copy local files
@@ -73,7 +73,7 @@ For most users this will suffice and anything in the root/ folder of the reposit
The most common paths to leverage for Linuxserver images will be: The most common paths to leverage for Linuxserver images will be:
* root/etc/cont-init.d/<98-script-name> - Contains init logic scripts that run before the services in the container start these should exit 0 and are ordered by filename * root/etc/cont-init.d/<98-script-name> - Contains init logic scripts that run before the services in the container start these should exit 0 and are ordered by filename
* root/etc/services.d/<yourservice>/run - Contains scripts that run in the foreground for persistent services IE NGINX * root/etc/services.d/`yourservice`/run - Contains scripts that run in the foreground for persistent services IE NGINX
* root/defaults - Contains base config files that are copied/modified on first spinup * root/defaults - Contains base config files that are copied/modified on first spinup
The example files in this repo contain a script to install sshutil and a service file to run the installed utility. The example files in this repo contain a script to install sshutil and a service file to run the installed utility.
@@ -82,7 +82,7 @@ The example files in this repo contain a script to install sshutil and a service
In this repository you will find the `Dockerfile.complex` containing: In this repository you will find the `Dockerfile.complex` containing:
``` ```Dockerfile
## Buildstage ## ## Buildstage ##
FROM lsiobase/alpine:3.9 as buildstage FROM lsiobase/alpine:3.9 as buildstage
@@ -111,41 +111,25 @@ Here we are leveraging a multi stage DockerFile to run custom logic and pull dow
## Full loop - getting a Mod to Dockerhub ## Full loop - getting a Mod to Dockerhub
First and foremost to publish a Mod you will need the following accounts: First and foremost to publish a Mod you will need the following accounts:
* Github- https://github.com/join
* DockerHub- https://hub.docker.com/signup
We recommend using this repository as a template for your first Mod, so in this section we assume the code is finished and we will only concentrate on plugging into Travis/Dockerhub. * Github- <https://github.com/join>
* DockerHub- <https://hub.docker.com/signup>
The only code change you need to make to the build logic file `.travis.yml` will be to modify the DOCKERHUB endpoint to your own image: We recommend using this repository as a template for your first Mod, so in this section we assume the code is finished and we will only concentrate on plugging into GitHub Actions/Dockerhub.
```
env: The only code change you need to make to the build logic file `.github/workflows/BuildImage.yml` will be to modify the DOCKERHUB endpoint to your own image:
global:
- DOCKERHUB="user/endpoint" ```yaml
DOCKERHUB: "user/endpoint"
``` ```
User is your Dockerhub user and endpoint is your own custom name. You do not need to create this endpoint beforehand, the build logic will push it and create it on first run. User is your Dockerhub user and endpoint is your own custom name. You do not need to create this endpoint beforehand, the build logic will push it and create it on first run.
Head over to https://travis-ci.org/ and click on signup: Head over to `https://github.com/user/endpoint/settings/secrets` and click on `New secret`
![signup](https://s3-us-west-2.amazonaws.com/linuxserver-docs/images/signup.png) Add `DOCKERUSER` and `DOCKERPASS`. These will be your live Dockerhub credentials:
This will use Github to auth you in. Once in the dashboard click on "Add new Repository": GitHub Actions will trigger a build off of your repo when you commit. The image will be pushed to Dockerhub on success. This Dockerhub endpoint is the Mod variable you can use to customize your container now.
![addnew](https://s3-us-west-2.amazonaws.com/linuxserver-docs/images/addnew.png)
Click on settings for the repo you want to add:
![settings](https://s3-us-west-2.amazonaws.com/linuxserver-docs/images/settings.png)
Under the "Environment Variables" section add DOCKERUSER and DOCKERPASS as shown below, these will be your live Dockerhub credentials:
![env](https://s3-us-west-2.amazonaws.com/linuxserver-docs/images/env.png)
Once these are set click on the "Current" tab and "Activate repository":
![activate](https://s3-us-west-2.amazonaws.com/linuxserver-docs/images/activate.png)
Travis will trigger a build off of your repo and will push to Dockerhub on success. This Dockerhub endpoint is the Mod variable you can use to customize your container now.
## Submitting a PR for a Mod to be added to the official LinuxServer.io repo ## Submitting a PR for a Mod to be added to the official LinuxServer.io repo
@@ -165,11 +149,11 @@ Travis will trigger a build off of your repo and will push to Dockerhub on succe
To inspect the file contents of external Mods dive is a great CLI tool: To inspect the file contents of external Mods dive is a great CLI tool:
https://github.com/wagoodman/dive <https://github.com/wagoodman/dive>
Basic usage: Basic usage:
``` ```bash
docker run --rm -it \ docker run --rm -it \
-v /var/run/docker.sock:/var/run/docker.sock \ -v /var/run/docker.sock:/var/run/docker.sock \
wagoodman/dive:latest <Image Name> wagoodman/dive:latest <Image Name>