Skip to content

Commit

Permalink
Move Makefile and docker-compose.yml to repo root (#1531)
Browse files Browse the repository at this point in the history
  • Loading branch information
myieye authored Oct 18, 2022
1 parent 2390f24 commit 999f83f
Show file tree
Hide file tree
Showing 14 changed files with 77 additions and 100 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

// Update the 'dockerComposeFile' list if you have more compose files or use different names.
// The .devcontainer/docker-compose.yml file contains any overrides you need/want to make.
"dockerComposeFile": ["../docker/docker-compose.yml", "docker-compose.yml"],
"dockerComposeFile": ["../docker-compose.yml", "docker-compose.yml"],

// The 'service' property is the name of the service for the container that VS Code should
// use. Update this value and .devcontainer/docker-compose.yml to the real service name.
Expand Down
4 changes: 0 additions & 4 deletions .github/workflows/build-and-publish-next.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ jobs:
# https://docs.docker.com/develop/develop-images/build_enhancements/
DOCKER_BUILDKIT: 1

defaults:
run:
working-directory: docker

steps:
-
uses: actions/checkout@v2
Expand Down
9 changes: 2 additions & 7 deletions .github/workflows/integrate-and-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@ jobs:
# https://docs.docker.com/develop/develop-images/build_enhancements/
DOCKER_BUILDKIT: 1

defaults:
run:
working-directory: docker

steps:
-
uses: actions/checkout@v2
Expand All @@ -53,7 +49,7 @@ jobs:
echo ::set-output name=TAG_NEXT_APP::${{ inputs.image-tag-next-app }}
echo ::set-output name=LFMERGE_NAMESPACE::ghcr.io/sillsdev/lfmerge
# Get LfMerge tag from Dockerfile, fallback to "latest" as default if that fails
TAG_LFMERGE=$(head -n 1 lfmerge/Dockerfile | cut -d: -f2)
TAG_LFMERGE=$(head -n 1 docker/lfmerge/Dockerfile | cut -d: -f2)
TAG_LFMERGE=${TAG_LFMERGE:-latest}
echo ::set-output name=TAG_LFMERGE::${TAG_LFMERGE}
-
Expand All @@ -76,9 +72,8 @@ jobs:
run: make unit-tests-ci
# -
# name: E2E Tests
# working-directory: .
# run: |
# docker-compose -f docker/docker-compose.yml up -d app-for-playwright
# docker-compose -f docker-compose.yml up -d app-for-playwright
# npx playwright install chromium
# npx playwright test
-
Expand Down
11 changes: 2 additions & 9 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@ name: Build and Test
on:
pull_request:

defaults:
run:
shell: bash
working-directory: docker

env:
DOCKER_BUILDKIT: 1

Expand All @@ -29,7 +24,7 @@ jobs:
with:
check_name: Unit Test Results
github_token: ${{ github.token }}
files: docker/PhpUnitTests.xml
files: PhpUnitTests.xml

build-app-run-e2e-tests:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -67,9 +62,8 @@ jobs:

-
name: Playwright E2E Tests
working-directory: .
# see https://playwright.dev/docs/ci#github-actions
run: npm run make playwright-tests
run: make playwright-tests

-
name: Upload test results
Expand All @@ -91,7 +85,6 @@ jobs:
cache: "npm"
-
name: Run prettier check
working-directory: .
run: npx prettier --check .

# protractor-tests:
Expand Down
1 change: 0 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@
"phpcs.composerJsonPath": "src",
"php.suggest.basic": false,
"git.ignoreLimitWarning": true,
"makefile.makeDirectory": "docker",
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
7 changes: 2 additions & 5 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,8 @@
{
"label": "Reset E2E tests",
"type": "process",
"command": "docker-compose",
"args": ["restart", "app-for-e2e"],
"options": {
"cwd": "docker"
},
"command": "docker",
"args": ["compose", "restart", "app-for-e2e"],
"problemMatcher": []
}
]
Expand Down
6 changes: 3 additions & 3 deletions docker/Makefile → Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ playwright-tests:
docker compose down

# delete any cached session storage state files if the service isn't running
docker compose ps app-for-playwright > /dev/null 2>&1 || rm -f ../*-storageState.json
docker compose ps app-for-playwright > /dev/null 2>&1 || rm -f *-storageState.json

docker compose up -d app-for-playwright

# wait until the app-for-playwright service is serving up HTTP before continuing
until curl localhost:3238 > /dev/null 2>&1; do sleep 1; done

cd .. && npx playwright install chromium && npx playwright test $(params)
npx playwright install chromium && npx playwright test $(params)

.PHONY: e2e-tests
e2e-tests:
Expand Down Expand Up @@ -57,7 +57,7 @@ build:
.PHONY: scan
# https://docs.docker.com/engine/scan
scan:
docker build -t lf-app:prod -f app/Dockerfile --platform linux/amd64 ..
docker build -t lf-app:prod -f docker/app/Dockerfile --platform linux/amd64 .
docker login
-docker scan --accept-license lf-app:prod > docker-scan-results.txt

Expand Down
80 changes: 40 additions & 40 deletions docker/docker-compose.yml → docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version: '3.5'
services:
ui-builder:
build:
context: ..
context: .
dockerfile: docker/ui-builder/Dockerfile
image: lf-ui-builder
container_name: lf-ui-builder
Expand All @@ -13,20 +13,20 @@ services:
- lf-ui-dist:/data/src/dist

# for developer convenience volume map
- ../webpack.config.js:/data/webpack.config.js
- ../webpack-dev.config.js:/data/webpack-dev.config.js
- ../webpack-prd.config.js:/data/webpack-prd.config.js
- ../package.json:/data/package.json
- ../package-lock.json:/data/package-lock.json
- ./webpack.config.js:/data/webpack.config.js
- ./webpack-dev.config.js:/data/webpack-dev.config.js
- ./webpack-prd.config.js:/data/webpack-prd.config.js
- ./package.json:/data/package.json
- ./package-lock.json:/data/package-lock.json

# needed these volume maps so changes to typescript/scss would be reflected in running app, actually rebundled and output to dist which is then shared to the app container.
- ../src/angular-app:/data/src/angular-app
- ../src/sass:/data/src/sass
- ../src/Site/views/languageforge/theme/default/sass:/data/src/Site/views/languageforge/theme/default/sass
- ./src/angular-app:/data/src/angular-app
- ./src/sass:/data/src/sass
- ./src/Site/views/languageforge/theme/default/sass:/data/src/Site/views/languageforge/theme/default/sass

app:
build:
context: ..
context: .
dockerfile: docker/app/Dockerfile
args:
- ENVIRONMENT=development
Expand Down Expand Up @@ -68,17 +68,17 @@ services:
- lf-ui-dist:/var/www/html/dist

# for developer convenience
- ../src/index.php:/var/www/src/index.php
- ../src/config.php:/var/www/src/config.php
- ../src/Api:/var/www/src/Api
- ../src/Site:/var/www/src/Site
- ./src/index.php:/var/www/src/index.php
- ./src/config.php:/var/www/src/config.php
- ./src/Api:/var/www/src/Api
- ./src/Site:/var/www/src/Site

# needed this volume mapping so changes to partials would be reflected in running app.
- ../src/angular-app:/var/www/src/angular-app
- ./src/angular-app:/var/www/src/angular-app

lfmerge:
build:
context: lfmerge
context: docker/lfmerge
dockerfile: Dockerfile
args:
- ENVIRONMENT=development
Expand Down Expand Up @@ -126,7 +126,7 @@ services:
- lf-caddy-config:/config

# for developer convenience
- ./ssl/Caddyfile:/etc/caddy/Caddyfile
- ./docker/ssl/Caddyfile:/etc/caddy/Caddyfile

next-proxy-dev:
image: caddy
Expand All @@ -143,11 +143,11 @@ services:
- NEXT_APP=next-app-dev:3000
volumes:
# for developer convenience
- ./next-app/dev/Caddyfile:/etc/caddy/Caddyfile
- ./docker/next-app/dev/Caddyfile:/etc/caddy/Caddyfile

next-app-dev:
build:
context: ../next-app
context: next-app
dockerfile: ../docker/next-app/dev/Dockerfile
image: lf-next-app-dev
container_name: lf-next-app-dev
Expand All @@ -156,12 +156,12 @@ services:
command: npm run dev-w-host
volumes:
# for developer convenience
- ../next-app/src:/app/src
- ../next-app/static:/app/static
- ./next-app/src:/app/src
- ./next-app/static:/app/static

next-proxy:
build:
context: next-app
context: docker/next-app
dockerfile: Dockerfile.proxy
image: lf-next-proxy
container_name: lf-next-proxy
Expand All @@ -175,7 +175,7 @@ services:

next-app:
build:
context: ../next-app
context: next-app
dockerfile: ../docker/next-app/Dockerfile.next-app
image: lf-next-app
container_name: lf-next-app
Expand Down Expand Up @@ -228,7 +228,7 @@ services:
- MYSQL_PASSWORD=not-a-secret
- MYSQL_ROOT_PASSWORD=also-not-a-secret
volumes:
- ./test-ld/schemas-and-data.sql:/docker-entrypoint-initdb.d/schemas-and-data.sql
- ./docker/test-ld/schemas-and-data.sql:/docker-entrypoint-initdb.d/schemas-and-data.sql

ld-api:
image: sillsdev/web-languagedepot-api
Expand All @@ -247,7 +247,7 @@ services:

test-e2e:
build:
context: ..
context: .
dockerfile: docker/test-e2e/Dockerfile
args:
- ENVIRONMENT=development
Expand All @@ -265,20 +265,20 @@ services:
command: sh -c "/wait && /run.sh"
volumes:
# for developer convenience
- ../src:/data/src
- ../typings:/data/typings
- ../webpack.config.js:/data/webpack.config.js
- ../webpack-dev.config.js:/data/webpack-dev.config.js
- ../webpack-prd.config.js:/data/webpack-prd.config.js
- ../package.json:/data/package.json
- ../package-lock.json:/data/package-lock.json
- ./src:/data/src
- ./typings:/data/typings
- ./webpack.config.js:/data/webpack.config.js
- ./webpack-dev.config.js:/data/webpack-dev.config.js
- ./webpack-prd.config.js:/data/webpack-prd.config.js
- ./package.json:/data/package.json
- ./package-lock.json:/data/package-lock.json
# uncomment on dev machine for convenience but don't commit - it messes up the e2e test run by
# clobbering the JS files produced by tsc in the built image.
# - ../test:/data/test

app-for-e2e:
build:
context: ..
context: .
dockerfile: docker/app-for-e2e/Dockerfile
image: app-for-e2e
container_name: app-for-e2e
Expand All @@ -300,7 +300,7 @@ services:

app-for-playwright:
build:
context: ..
context: .
dockerfile: docker/app/Dockerfile
args:
- ENVIRONMENT=development
Expand Down Expand Up @@ -328,12 +328,12 @@ services:
extra_hosts:
- "host.docker.internal:host-gateway"
volumes:
- ../test/e2e/utils/TestControl.php:/var/www/src/Api/Service/TestControl.php
- ../test/e2e/shared-files:/tmp/e2e-shared-files
- ./test/e2e/utils/TestControl.php:/var/www/src/Api/Service/TestControl.php
- ./test/e2e/shared-files:/tmp/e2e-shared-files

test-php:
build:
context: ..
context: .
dockerfile: docker/test-php/Dockerfile
image: test-php
container_name: test-php
Expand All @@ -357,9 +357,9 @@ services:
command: sh -c "/wait && /run.sh"
volumes:
# for developer convenience
- ../test:/var/www/test
- ../src/Api:/var/www/src/Api
- ../src/Site:/var/www/src/Site
- ./test:/var/www/test
- ./src/Api:/var/www/src/Api
- ./src/Site:/var/www/src/Site

volumes:
lf-caddy-config:
Expand Down
12 changes: 6 additions & 6 deletions docs/DEVELOPER.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@ On Windows, the project should be opened with the [Remote - WSL](https://marketp

### Running the App Locally

> Note: `make` rules can be run directly from the `docker` directory or with `npm run make` from any project sub-directory.
> Note: `make` rules can be run directly from the root directory or with `npm run make` from any project sub-directory.
1. `npm run make` or `cd docker && make`
1. Within any browser, navigate to https://localhost
1. Continue through any certificate warnings
1. You should see a landing page, click "Login"
1. Use `admin` and `password` to login
1. `make` or `npm run make`
2. Within any browser, navigate to https://localhost
3. Continue through any certificate warnings
4. You should see a landing page, click "Login"
5. Use `admin` and `password` to login

Note: The application is accessible via HTTP or HTTPS. HTTPS is required for service-worker functionality.

Expand Down
2 changes: 1 addition & 1 deletion next-app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ See [Developer Guide](docs/DEVELOPER.md) for the quick start instructions.

### Alternate local development (full infrastructure)

From within the `/docker` directory, `make next-dev` and access app via http://localhost
From the project root directory, `make next-dev` and access app via http://localhost

### Alternate local development (limited)

Expand Down
Loading

0 comments on commit 999f83f

Please sign in to comment.