Problem
I’ve been trying to setup a SurrealDB container within my test job in GitHub Actions. The step I am currently struggling with is that I can’t find a way to expose the ports on my surreal-db custom docker action. Previously, I have also tried using a service container (my understanding is that the service container is usually used for that purpose).
Attempts to solve it
- Running it as a service container:
test:
name: Test
runs-on: ubuntu-latest
env:
SURREAL_USER: ${{ secrets.SURREAL_USER }}
SURREAL_PASS: ${{ secrets.SURREAL_PASS }}
SURREAL_PORT: ${{ vars.SURREAL_PORT }}
steps:
- uses: actions/checkout@v4
...
services:
db:
image: surrealdb/surrealdb:latest
# Problem here is that I can't use the entrypoint property to launch the server
ports:
- ${{ vars.SURREAL_PORT }:8000
- Creating a custom GitHub action to run it
...
inputs:
surreal-user:
description: "Username for the account"
required: false
default: "root"
surreal-pass:
description: "Password for the account"
required: false
default: "root"
surreal-port:
description: "Port to expose on the host machine"
required: false
default: "8000"
runs:
using: "docker"
image: docker://surrealdb/surrealdb:latest
entrypoint: "entrypoint.sh"
args:
- ${{ inputs.surreal-user }}
- ${{ inputs.surreal-pass }}
- ${{ inputs.surreal-port }}
# ... and here I can't use the ports property
I am thinking that there must be a way to expose the ports somehow. Anyone know how? Or do you have an alternative way of working around that problem?
2
Answers
Instead of creating a custom Docker action or using a service container, you can use the official surrealdb/setup-surreal@v1 action. This action is specifically designed to set up and run SurrealDB in GitHub Actions.
Can you try something like the following and let me know if that worked? Also use the official surrealdb/setup-surreal@v1 action.