update docker

This commit is contained in:
Sean Macfarlane
2020-04-17 11:27:34 -04:00
parent b820ff2c41
commit 4a7f057169
5 changed files with 82 additions and 18 deletions

View File

@@ -1,16 +0,0 @@
name: Docker Image CI
on:
push:
branches: [ master ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Build the Docker image
run: docker build . --file Dockerfile --tag wlan-cloud-graphql-gw:$(date +%s)

76
.github/workflows/dockerpublish.yml vendored Normal file
View File

@@ -0,0 +1,76 @@
name: Docker Publish
on:
push:
# Publish `master` as Docker `latest` image.
branches:
- master
# Publish `v1.2.3` tags as releases.
tags:
- v*
# Run tests for any PRs.
pull_request:
env:
IMAGE_NAME: wlan-cloud-graphql-gw
jobs:
# Run tests.
# See also https://docs.docker.com/docker-hub/builds/automated-testing/
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Run tests
run: |
if [ -f docker-compose.test.yml ]; then
docker-compose --file docker-compose.test.yml build
docker-compose --file docker-compose.test.yml run sut
else
docker build . --file Dockerfile
fi
push:
# Ensure test job passes before pushing image.
needs: test
runs-on: ubuntu-latest
if: github.event_name == 'push'
steps:
- uses: actions/checkout@v2
- name: Build image
run: docker build . --file Dockerfile --tag image
- name: Login to TIP Docker registry
uses: azure/docker-login@v1
with:
login-server: tip-tip-wlan-cloud-docker-repo.jfrog.io
username: build-pipeline
password: ${{ secrets.REPO_PASSWORD }}
- name: Push image
run: |
IMAGE_ID=${{ github.repository }}/$IMAGE_NAME
# Change all uppercase to lowercase
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
# Strip git ref prefix from version
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
# Strip "v" prefix from tag name
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
# Use Docker `latest` tag convention
[ "$VERSION" == "master" ] && VERSION=latest
echo IMAGE_ID=$IMAGE_ID
echo VERSION=$VERSION
docker tag image $IMAGE_ID:$VERSION
docker push $IMAGE_ID:$VERSION

View File

@@ -10,10 +10,10 @@ COPY package*.json ./
#RUN npm install
# If you are building your code for production
RUN npm ci --only=production
RUN npm install
# Bundle app source
COPY . .
EXPOSE 4000
CMD [ "npm", "start" ]
CMD [ "npm", "run", "prod" ]

3
docker-compose.test.yml Normal file
View File

@@ -0,0 +1,3 @@
sut:
build: .
command: npm test

View File

@@ -21,6 +21,7 @@
},
"scripts": {
"start": "NODE_ENV=development node -r esm src/index.js",
"prod": "node -r esm src/index.js",
"test": "echo \"Error: no test specified\" && exit 1",
"format": "prettier --write \"src/**/*.js\"",
"eslint-fix": "eslint --fix . --ext .js --ext .gql --ext .graphql --max-warnings=0"