Skip to content

Commit

Permalink
Add official docker support
Browse files Browse the repository at this point in the history
  • Loading branch information
pedrofaria committed Oct 6, 2023
1 parent dd883a9 commit 9c7d1d9
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 65 deletions.
26 changes: 25 additions & 1 deletion .github/workflows/build-and-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ 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\//}
Expand All @@ -25,3 +25,27 @@ jobs:
artifacts: 'releases/accweb_${{ steps.get_version.outputs.VERSION }}.zip'
generateReleaseNotes: true
token: ${{ secrets.GITHUB_TOKEN }}
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
# list of Docker images to use as base name for tags
images: |
name/app
# 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:
build-args: |
VERSION=${{ steps.get_version.outputs.VERSION }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## next
* 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
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

0 comments on commit 9c7d1d9

Please sign in to comment.