Skip to content

Commit

Permalink
Add official docker support (#253)
Browse files Browse the repository at this point in the history
* Add official docker support

* fix actions

* fix

* fix2

* here we go

* fix

* cleanups and doc update
  • Loading branch information
pedrofaria authored Oct 6, 2023
1 parent dd883a9 commit 8aa71d6
Show file tree
Hide file tree
Showing 10 changed files with 2,782 additions and 8,124 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/build-and-push-docker.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Build and Push accweb Docker Image
on:
push:
tags:
- '*'
jobs:
build-docker-accweb:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout and setup
uses: actions/checkout@v2

- name: Get the version
id: get_version
run: echo "VERSION=${GITHUB_REF/refs\/tags\//}" >> "$GITHUB_OUTPUT"

- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
# list of Docker images to use as base name for tags
images: accweb/accweb
# generate Docker tags based on the following events/attributes
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v5
with:
push: true
build-args: |
VERSION=${{ steps.get_version.outputs.VERSION }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
4 changes: 2 additions & 2 deletions .github/workflows/build-and-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ jobs:
- name: Setup go
uses: actions/setup-go@v2
with:
go-version: '^1.17.7'
go-version: '^1.21.0'
- name: Get the version
id: get_version
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}
run: echo "VERSION=${GITHUB_REF/refs\/tags\//}" >> "$GITHUB_OUTPUT"
- name: Build accweb release
run: chmod u+x ./build/build_release.sh && ./build/build_release.sh ${{ steps.get_version.outputs.VERSION }}
- uses: ncipollo/release-action@v1
Expand Down
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# Changelog

## next
## 1.22.0
* Fix arm64 node dependencies
* Fix live view for non numeric instance ids
* Add official docker support

## 1.21.0
* Add Morocoo nationality #245
Expand Down
51 changes: 29 additions & 22 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,31 +1,38 @@
FROM golang AS build
FROM golang:1-bullseye AS builder

LABEL maintainer="Kugel" \
contributors="GillesDubois" \
version="latest" \
description="Assetto Corsa Competizione Server Management Tool via Web Interface."
ARG VERSION=docker

COPY . /go/src/github.com/assetto-corsa-web/accweb
ENV NODE_MAJOR=16

WORKDIR /go/src/github.com/assetto-corsa-web/accweb
RUN apt-get update && apt-get install -y ca-certificates curl gnupg
RUN mkdir -p /etc/apt/keyrings
RUN curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
RUN echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list

RUN apt update && \
apt upgrade -y && \
apt install curl -y
RUN curl -sL https://deb.nodesource.com/setup_14.x -o nodesource_setup.sh && bash nodesource_setup.sh
RUN apt-get install -y nodejs
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
&& apt-get install -y git build-essential nodejs zip

ENV GOPATH=/go
RUN go build -tags netgo -a -v -ldflags "-s -w" main.go
WORKDIR /accweb_src

RUN cd /go/src/github.com/assetto-corsa-web/accweb/public && npm i && npm rebuild node-sass && npm run build
COPY . /accweb_src

# Final image
FROM ubuntu:bionic
RUN sh build/build_release.sh ${VERSION}
RUN cd /accweb_src/releases && unzip accweb_${VERSION}.zip && mv accweb_${VERSION} /accweb

COPY --from=build /go/src/github.com/assetto-corsa-web/accweb /accweb
FROM alpine:3.18

ENV ACCWEB_HOST=localhost:8080 \
LABEL description="Assetto Corsa Competizione Server Management Tool via Web Interface."

ARG VERSION=noversion

RUN apk add --no-cache gettext wine ca-certificates

RUN mkdir /accserver && mkdir /accweb

COPY --from=builder /accweb/accweb /accweb/accweb
COPY --from=builder /accweb_src/build/docker/* /accweb/

ENV ACCWEB_HOST=0.0.0.0:8080 \
ACCWEB_ENABLE_TLS=false \
ACCWEB_CERT_FILE=/sslcerts/certificate.crt \
ACCWEB_PRIV_FILE=/sslcerts/private.key \
Expand All @@ -39,8 +46,8 @@ VOLUME /accserver /accweb /sslcerts

WORKDIR /accweb

RUN apt -y update && apt -y install gettext-base wine64-development wine-development libwine-development libwine-development-dev

EXPOSE 8080

ENTRYPOINT [ "/bin/sh", "-c", "/accweb/build/docker/docker-entrypoint.sh" ]
ENTRYPOINT [ "sh", "/accweb/docker-entrypoint.sh" ]

CMD [ "start" ]
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

dev-setup:
cd public; npm install; npm run build
cp dev_config.yml config.yml
Expand Down
30 changes: 15 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,17 @@ The successor of [acweb](https://github.com/assetto-corsa-web/acweb)! accweb let

1. [Features](#features)
2. [Changelog](#changelog)
3. [Installation](#installation)
4. [Backup](#backup)
5. [Contribute and support](#support)
6. [Build release](#release)
7. [Links](#links)
8. [License](#license)
9. [ACCWeb Discord Server](#discord)
3. [Installation](#installation-and-configuration)
4. [Docker](#docker)
5. [Backup](#backup)
6. [Contribute and support](#contribute-and-support)
7. [Build release](#build-release)
8. [Links](#links)
9. [License](#license)
10. [ACCWeb Discord Server](#accweb-discord-server)


## Features
<a name="features" />

* create and manage as many server instances as you like
* configure your instances in browser
Expand All @@ -39,7 +40,6 @@ The successor of [acweb](https://github.com/assetto-corsa-web/acweb)! accweb let
See [CHANGELOG.md](CHANGELOG.md).

## Installation and configuration
<a name="installation" />

accweb is installed by extracting the zip on your server, modifing the YAML configuration file to your needs and starting it in a terminal.

Expand All @@ -58,13 +58,17 @@ I recommend to setup an SSL certificate, but that's out of scope for this instru

**Note that you have to install [wine](https://www.winehq.org/) if you're on Linux.**

## Docker

Please visite our [Docker Hub repository](https://hub.docker.com/r/accweb/accweb) for more information.

https://hub.docker.com/r/accweb/accweb

## Backup
<a name="backup" />

To backup your files, copy and save the `config` directory as well as the `config.yml`. The `config` directory can later be placed inside the new accweb version directory and you can adjust the new `config.yml` based on your old configuration (don't overwrite it, there meight be breaking changes).

## Contribute and support
<a name="support" />

If you like to contribute, have questions or suggestions you can open tickets and pull requests on GitHub.

Expand Down Expand Up @@ -99,7 +103,6 @@ Keep in mind that you need to restart the command for see the changes that you m
There is a pre-built development environment setup for ACCWeb for Visual Studio Code and Remote Containers. Please, check here how to setup and use: https://code.visualstudio.com/docs/remote/containers

## Build release
<a name="release" />

To build a release, execute the `build_release.sh` script (on Linux) or follow the steps inside the script. You need to pass the build version as the first parameter. Example:
To build a release, execute the `build_release.sh` script (on Linux) or follow the steps inside the script. You need to pass the build version as the first parameter. Example:
Expand All @@ -111,18 +114,15 @@ To build a release, execute the `build_release.sh` script (on Linux) or follow t
This will create a directory `releases/accweb_1.2.3` containing the release build of accweb. This directory can be zipped, uploaded to GitHub and deployed on a server.

## Links
<a name="links" />

* [Docker Hub](https://cloud.docker.com/repository/docker/kugel/accweb/general)
* [Assetto Corsa Forums](https://www.assettocorsa.net/forum/index.php?threads/release-accweb-assetto-corsa-competizione-server-management-tool-via-web-interface.57572/)

## License
<a name="license" />

MIT

## ACCWeb Discord Server
<a name="discord" />

Join us on our Discord server to get and provide support.

Expand Down
22 changes: 8 additions & 14 deletions build/docker/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
#!/bin/bash
#!/bin/sh

# Move to working dir
cd /accweb
command=$1

# Remove default config file
rm -rf config.yml

# envsubst to replace set config properly
envsubst < build/docker/docker_config.yml > config.yml

# Run winecfg
winecfg

# Launch accweb main
./main
if [ $command = "start" ]; then
envsubst < docker_config.yml > config.yml
./accweb
else
exec "$@"
fi
27 changes: 0 additions & 27 deletions build/docker/docker_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,50 +2,23 @@
# https://github.com/assetto-corsa-web/accweb

webserver:
# Sets the host and port.
# Port 80 is the default port for web servers and might be blocked on your maschine.
# If that is the case you can use anything else like 8080 for example.
host: $ACCWEB_HOST

# Set tls to true and provide paths to the key files in order to enable SSL.
# This is highly recommended as otherwise your passwords and all other traffic won't be encrypted!
# accweb will probably support automatic Letsencrypt certificates in the future.
tls: $ACCWEB_ENABLE_TLS
cert: $ACCWEB_CERT_FILE
private_key: $ACCWEB_PRIV_FILE

# http write/read timeouts
# technical stuff you shouldn't mess around with
write_timeout: 5
read_timeout: 5

auth:
# Set the admin, moderator and read only user password.
# accweb won't start without an admin password.
admin_password: $ACCWEB_ADMIN_PASSWORD
moderator_password: $ACCWEB_MOD_PASSWORD
read_only_password: $ACCWEB_RO_PASSWORD

# Optional path to public and private token key files. If you need to store the private/public keys used to
# sign the session token (the JWT) in a specific location (or have existing keys in a specific location), you
# can define those here.
#
# accweb now generate these with a default path if not configured.
#
# public_key_path: secrets/token.public
# private_key_path: secrets/token.private

acc:
# Path to ACC server installation directory.
# Use forward slashes (even if you're on Windows!). The example path is for Linux.
server_path: "/accserver"

# Name of the server executable within the server installation directory.
# You don't need to change this (except the ACC devs change its name for some reason).
server_exe: accServer.exe

# TECHNICAL STUFF FROM HERE ON

config_path: config/
dev: false
loglevel: $ACCWEB_LOGLEVEL
Expand Down
Loading

0 comments on commit 8aa71d6

Please sign in to comment.