Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: docker build and docker run workflows #124

Closed
wants to merge 13 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
.gitignore
7 changes: 7 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,10 @@ jobs:
run: pnpm run test:unit
- name: Run e2e tests
run: pnpm run test:e2e

docker:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Build Docker image and run tests
run: bash test-docker.sh
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,16 @@ RUN npm i -g pnpm
COPY package.json .
COPY tsconfig.json .

COPY pnpm-lock.yaml* ./

RUN pnpm install

COPY . .

RUN pnpm db:generate-types
RUN pnpm build

RUN pnpm prune --prod
RUN pnpm prune --prod --no-optional --ignore-scripts

FROM base as release

Expand Down
32 changes: 32 additions & 0 deletions test-docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash
set -e

echo "Building Docker image..."
docker build -t culero-api .

echo "Starting necessary containers with Docker Compose..."
docker-compose up -d

echo "Running Docker container..."
docker run --rm -d \
-e DATABASE_URL="postgresql://dummy:dummy@localhost:5432/dummy" \
-e JWT_SECRET="dummy_secret" \
-e REDIS_URL="redis://localhost:6379" \
--name culero-api-test \
culero-api

sleep 10

if [ "$(docker inspect -f '{{.State.Running}}' culero-api-test)" = "true" ]; then
echo "Docker container is running successfully."
else
echo "Docker container failed to start."
exit 1
fi


echo "Cleaning up..."
docker stop culero-api-test
docker-compose down

echo "Docker build and run tests completed successfully."
Loading