Skip to content

Commit

Permalink
service starts with docker compose up
Browse files Browse the repository at this point in the history
  • Loading branch information
ignisco committed May 20, 2024
1 parent 96420f5 commit 13d5075
Show file tree
Hide file tree
Showing 69 changed files with 138 additions and 412 deletions.
63 changes: 63 additions & 0 deletions .github/workflows/enochecker_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: enochecker_test

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
build:
runs-on: self-hosted
env:
ENOCHECKER_TEST_CHECKER_ADDRESS: localhost
ENOCHECKER_TEST_CHECKER_PORT: 5008

steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Install enochecker_test
run: |
python -m pip install --upgrade pip
pip install enochecker-test
- name: start service
run: |
cd service
docker-compose up --build --force-recreate -d
- name: start checker
run: |
cd checker
docker-compose up --build --force-recreate -d
- name: obtain Docker host IP
run: |
echo "ENOCHECKER_TEST_SERVICE_ADDRESS=$(ip -4 address show dev eth0 | grep inet | awk '{ print $2 }' | sed 's|/.*$||')" >> $GITHUB_ENV
- name: run enochecker_test
run: |
enochecker_test
- name: Dump docker logs on failure
if: failure()
uses: jwalton/gh-docker-logs@v1
with:
dest: './logs'
- name: Tar logs
if: failure()
run: tar cvzf ./logs.tgz ./logs
- name: Upload logs to GitHub
if: failure()
uses: actions/upload-artifact@master
with:
name: logs.tgz
path: ./logs.tgz
- name: Kill docker containers
if: failure() || success()
run: |
(cd service && docker-compose kill)
(cd checker && docker-compose kill)
9 changes: 9 additions & 0 deletions debug/dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM ubuntu:22.04
RUN apt-get update && apt-get install -y gcc python3 make gdb


# Set the working directory inside the container to /mnt
WORKDIR /mnt

# Optional: Start a shell when the container runs, good for development
CMD ["sh"]
1 change: 1 addition & 0 deletions debug/kleinmazama.hex

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions service/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# This file contains ignore-rules for files that are not tracked by docker for container builds.
data/
.git/
Dockerfile
docker-compose.yml
.dockerignore
.gitignore
.env
2 changes: 2 additions & 0 deletions service/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Docker-compose might get confused when there are multiple "service" directories, so let's help it by providing a specific project name.
COMPOSE_PROJECT_NAME=pirateprattle_service
3 changes: 3 additions & 0 deletions .gitignore → service/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Use https://gitignore.io/ to create a suitable .gitignore file for your project.
data/

# Prerequisites
*.d

Expand Down
11 changes: 11 additions & 0 deletions service/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: "3"
services:
pirateprattle:
build: .
# The code should be copied into the container using COPY.
# Mount the data folder writable, so that information can be persisted across restarts.
volumes:
- ./data/:/data:rw
# Define the port mapping (external:internal port)
ports:
- "4444:4444"
24 changes: 20 additions & 4 deletions service/dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,25 @@
# Use a suitable base-image.
FROM ubuntu:22.04
RUN apt-get update && apt-get install -y gcc python3 make gdb

# Create a seperate user and chown new directories if necessary
RUN addgroup --system service
RUN adduser --system --ingroup service --uid 1000 service

# Set the working directory inside the container to /mnt
WORKDIR /mnt
# Create our mapped data volume endpoint
RUN mkdir /data/

# Optional: Start a shell when the container runs, good for development
CMD ["sh"]
# Copy our entrypoint.sh and make it executable
COPY entrypoint.sh /
RUN chmod +x /entrypoint.sh

# Copy our service (using 'src' here because the reference to splash_screen.txt is hardcoded, so needs to be same as the original)
COPY src/ /src/

# Change the working directory.
WORKDIR /src/
# Expose the service's port
EXPOSE 4444

# Run the service
ENTRYPOINT ["/entrypoint.sh"]
12 changes: 12 additions & 0 deletions service/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/sh
set -e
set -x

# Chown the mounted data volume
chown -R service:service "/data/"

# Build the project
make

# Launch our service as user 'service'
exec su -s /bin/sh -c './pirateprattle' service
Binary file removed service/my_server
Binary file not shown.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

8 changes: 0 additions & 8 deletions service/root/BuccaneerBeach/rogue_bonny_cheating_on_exams.log

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

8 changes: 0 additions & 8 deletions service/root/GalleonGraveyard/red_hook_cheating_on_exams.log

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 13d5075

Please sign in to comment.