Skip to content

Commit

Permalink
Merge pull request #43 from MitchTalmadge/staging
Browse files Browse the repository at this point in the history
New AMP Update Strategy
  • Loading branch information
MitchTalmadge authored Nov 28, 2020
2 parents b26388e + 1263b7d commit 1250968
Show file tree
Hide file tree
Showing 7 changed files with 87 additions and 71 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/auto-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Auto Release

on:
workflow_dispatch:
schedule:
- cron: "0 * * * *" # Every hour
release:
types:
- created

jobs:
check-for-updates:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Download AMP Versions
run: wget https://cubecoders.com/AMPVersions.json -O /tmp/AMPVersions.json

- name: Parse Versions
run: |
echo "LATEST_RELEASE_VERSION=$(git tag -l --sort=-refname | grep -E '^v?[0-9]$' -m 1)" >> $GITHUB_ENV
echo "AMP_CORE_VERSION=$(jq -r '.AMPCore' /tmp/AMPVersions.json | sed -e 's/\.//g')" >> $GITHUB_ENV
echo "AMP_INST_MGR_VERSION=$(jq -r '.InstanceManagerCLI' /tmp/AMPVersions.json | sed -e 's/\.//g')" >> $GITHUB_ENV
- name: Create Tag
run: |
git config user.name github-actions
git config user.email [email protected]
git tag -a "$LATEST_RELEASE_VERSION-ampcore$AMP_CORE_VERSION-ampinstmgr$AMP_INST_MGR_VERSION" -m "Auto Release Latest AMP Version" || { echo "Already up-to-date"; exit; }
git push --follow-tags
2 changes: 1 addition & 1 deletion .github/workflows/main.yml → .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: CI
name: Test

on: [push, pull_request]

Expand Down
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
.idea
.vscode
*.iml
data*
docker-compose.yml
test
test
55 changes: 38 additions & 17 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ ENV MODULE=ADS

ARG DEBIAN_FRONTEND=noninteractive


# Initialize
RUN apt-get update && \
apt-get install -y --no-install-recommends \
jq \
sed \
wget && \
apt-get -y clean && \
apt-get -y autoremove --purge && \
Expand Down Expand Up @@ -73,46 +73,67 @@ RUN wget -O /tmp/cacert.pem https://curl.haxx.se/ca/cacert.pem && \
cert-sync /tmp/cacert.pem


# Install dependencies for various game servers.
# Install AMP dependencies
RUN ls -al /usr/local/bin/
RUN apt-get update && \
apt-get install -y \
# --------------------
# Dependencies for AMP:
tmux \
git \
socat \
unzip \
iputils-ping \
procps \
# --------------------
# Dependencies for Minecraft:
openjdk-8-jre-headless \
# --------------------
# Dependencies for srcds (TF2, GMod, ...)
libcurl4 \
lib32gcc1 \
lib32stdc++6 \
lib32tinfo5 \
xz-utils && \
# --------------------
# Dependencies for Factorio:
xz-utils \
# --------------------
&& \
apt-get -y clean && \
apt-get -y autoremove --purge && \
rm -rf \
/tmp/* \
/var/lib/apt/lists/* \
/var/tmp/*


# Manually install AMP (Docker doesn't have systemctl and other things that AMP's deb postinst expects).
# Manually install ampinstmgr by extracting it from the deb package.
# Docker doesn't have systemctl and other things that AMP's deb postinst expects,
# so we can't use apt to install ampinstmgr.
RUN apt-get update && \
apt-get install -y --no-install-recommends \
tmux \
git \
socat \
unzip \
iputils-ping \
procps && \
software-properties-common \
dirmngr \
apt-transport-https && \
# Add CubeCoders repository and key
apt-key adv --fetch-keys http://repo.cubecoders.com/archive.key && \
apt-add-repository "deb http://repo.cubecoders.com/ debian/" && \
apt-get update && \
# Just download (don't actually install) ampinstmgr
apt-get install -y --no-install-recommends --download-only ampinstmgr && \
# Extract ampinstmgr from downloaded package
mkdir -p /tmp/ampinstmgr && \
dpkg-deb -x /var/cache/apt/archives/ampinstmgr_*.deb /tmp/ampinstmgr && \
mv /tmp/ampinstmgr/opt/cubecoders/amp/ampinstmgr /usr/local/bin/ampinstmgr && \
apt-get -y clean && \
apt-get -y autoremove --purge && \
rm -rf \
/tmp/* \
/var/lib/apt/lists/* \
/var/tmp/*


# Create ampinstmgr install directory.
# ampinstmgr will be downloaded later when the image is started for the first time.
RUN mkdir -p /home/amp/.ampdata/.bin && \
ln -s /home/amp/.ampdata/.bin/ampinstmgr /usr/local/bin/ampinstmgr

# Get the latest AMP Core to pre-cache upgrades.
RUN wget https://cubecoders.com/AMPVersions.json -O /tmp/AMPVersions.json && \
wget https://cubecoders.com/Downloads/AMP_Latest.zip -O /opt/AMPCache-$(cat /tmp/AMPVersions.json | jq -r '.AMPCore' | sed -e 's/\.//g').zip

# Set up environment
COPY entrypoint /opt/entrypoint
Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
# AMP-dockerized
[![Docker Cloud Build Status](https://img.shields.io/docker/cloud/build/mitchtalmadge/amp-dockerized)](https://hub.docker.com/r/mitchtalmadge/amp-dockerized)

This repository bundles [CubeCoders AMP](https://cubecoders.com/AMP) into a Debian-based [Docker image.](https://hub.docker.com/r/mitchtalmadge/amp-dockerized)
(`mitchtalmadge/amp-dockerized:latest`)
This repository bundles [CubeCoders AMP](https://cubecoders.com/AMP) into a Debian-based [Docker image.](https://hub.docker.com/r/mitchtalmadge/amp-dockerized)
(`mitchtalmadge/amp-dockerized:latest`) so that you can set up game servers with ease!

In a nutshell, AMP (Application Management Panel) allows you to manage one or more game servers from a web UI.
In a nutshell, AMP (Application Management Panel) allows you to manage one or more game servers from a web UI. You need a [CubeCoders AMP Licence](https://cubecoders.com/AMP#buyAMP) to use this image.

*Disclaimer:* I (Mitch Talmadge) did not create AMP and am not associated with CubeCoders. I simply made it work with Docker because
I hate installing things.
Updates to AMP are automatically bundled into new Docker images. We check for updates hourly.

*Please note:* This is a community-made unofficial image, and is not endorsed by CubeCoders.

# Getting Help

Expand Down Expand Up @@ -173,8 +174,7 @@ Or, just put [CloudFlare](https://www.cloudflare.com/) and its free SSL cert in

# Upgrading AMP

AMP is automatically upgraded to the latest version when the container is restarted. If a newer version of AMP exists
than the one that is running, it will be downloaded and installed before the instances are started. :D Yay
To upgrade, all you have to do is pull our latest Docker image! We automatically check for AMP updates every hour. When a new version is released, we build and publish an image both as a standalone tag and on `:latest`.

# Contributing

Expand Down
10 changes: 6 additions & 4 deletions entrypoint/main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,11 @@ if [ ${LICENCE} = "notset" ]; then
exit 1
fi

# Update the instance manager.
echo "Checking for ampinstmgr updates..."
/bin/bash /opt/entrypoint/update-ampinstmgr.sh
# Copy the pre-cached AMP Core from the image into the location AMP expects.
# This will allow upgrades to use the cache and not need to do any downloads.
echo "Copying AMP Core..."
mkdir -p /home/amp/.ampdata/instances/
cp /opt/AMPCache* /home/amp/.ampdata/instances/

# Create Main Instance if not exists
echo "Making sure Main instance exists..."
Expand All @@ -72,7 +74,7 @@ else
fi

# Upgrade instances
echo "Upgrading Instances... (This can take a while)"
echo "Upgrading Instances..."
su ${APP_USER} --command "ampinstmgr UpgradeAll" | grep --line-buffered -v -E '\[[-#]+\]'

# Set Main instance to start on boot if not already.
Expand Down
40 changes: 0 additions & 40 deletions entrypoint/update-ampinstmgr.sh

This file was deleted.

0 comments on commit 1250968

Please sign in to comment.