Skip to content

Commit

Permalink
Merge pull request #12 from murtll/ci/new-dockerfile
Browse files Browse the repository at this point in the history
move to alpine image
  • Loading branch information
murtll authored Mar 14, 2023
2 parents ecb3529 + 99b252b commit dd7e784
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 20 deletions.
39 changes: 25 additions & 14 deletions .github/workflows/build_run.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,22 @@ on:
- '.github/workflows/check_compose.yml'
- 'docker-compose.yml'

env:
PORT: 3000
DB_NAME: test
DB_USER: test
DB_PASSWORD: test
DB_HOST: test-db
NETWORK: test-net
CONTAINER_NAME: test

jobs:
build_run:
name: Build and run
runs-on: ubuntu-latest
concurrency:
group: ${{ github.job }}-pr-${{ github.head_ref }}-to-${{ github.base_ref }}
cancel-in-progress: true
steps:
- uses: actions/checkout@v3

Expand All @@ -26,19 +38,25 @@ jobs:
context: .
push: false
tags: ${{ github.registry }}
cache-from: type=registry,ref=${{ vars.DOCKER_REGISTRY }}/${{ github.repository }}:buildcache
cache-from: type=registry,ref=${{ vars.DOCKER_REGISTRY }}/${{ github.repository }}-buildcache:${{ github.base_ref }}

- name: Run container
- name: Create network
run: |
docker network create ${{ env.NETWORK }} --attachable
- name: Run db container
run: |
docker run -d \
--name ${{ env.DB_HOST }} \
--network ${{ env.NETWORK }} \
-e POSTGRES_USER=${{ env.DB_USER }} \
-e POSTGRES_PASSWORD=${{ env.DB_PASSWORD }} \
-e POSTGRES_DB=${{ env.DB_NAME }} postgres:14-alpine
- name: Run container
run: |
docker run -d \
--name test \
--name ${{ env.CONTAINER_NAME }} \
--network ${{ env.NETWORK }} \
-e NODE_ENV=master \
-e PORT=${{ env.PORT }} \
Expand All @@ -49,21 +67,14 @@ jobs:
-e DB_PASSWORD=${{ env.DB_PASSWORD }} \
-e SESSION_SECRET=fakesecret ${{ github.repository }}
sleep 5
docker exec test wget --no-verbose --tries=1 --spider http://localhost:${{ env.PORT }}/
env:
PORT: 3000
DB_NAME: test
DB_USER: test
DB_PASSWORD: test
DB_HOST: test-db
NETWORK: test
docker exec ${{ env.CONTAINER_NAME }} wget --no-verbose --tries=1 --spider http://localhost:${{ env.PORT }}/
- name: Test migrations and seeds
run: |
docker exec test yarn migrate
docker exec test yarn seed
docker exec ${{ env.CONTAINER_NAME }} yarn migrate
docker exec ${{ env.CONTAINER_NAME }} yarn seed
- name: Tail logs
if: ${{ failure() }}
run: |
docker logs test
docker logs ${{ env.CONTAINER_NAME }}
7 changes: 2 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
FROM node:17-buster-slim
FROM node:17-alpine

WORKDIR /app

RUN apt update && apt install build-essential python wget -y

COPY package.json ./
COPY yarn.lock ./
COPY package.json yarn.lock ./

RUN yarn && yarn global add knex

Expand Down
2 changes: 1 addition & 1 deletion entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/sh
set -e

while test $# != 0
Expand Down

0 comments on commit dd7e784

Please sign in to comment.