-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from zeeshanakram3/docker-image-and-github-ci-s…
…etup Docker image and GitHub CI setup
- Loading branch information
Showing
13 changed files
with
170 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# DEFAULT DOCKER ENVIRONMENT | ||
|
||
# DB_HOST is placed here instead of .env file, because the migration script | ||
# loads .env and it would cause migration script to use `squid_db` instead | ||
# of `localhost` as DB_HOST, causing the migration script to fail. | ||
|
||
# Docker db config | ||
DB_HOST=squid_db |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
name: Checks | ||
on: [push, pull_request] | ||
|
||
jobs: | ||
local: | ||
name: Local build, linting and formatting | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: [ubuntu-latest] | ||
node-version: [16.x] | ||
fail-fast: true | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Use Node.js ${{matrix.node-version}} | ||
uses: actions/setup-node@v1 | ||
with: | ||
node-version: ${{matrix.node-version}} | ||
- name: Install npm packages | ||
run: npm ci | ||
- name: Run checks | ||
run: npm run checks | ||
docker: | ||
name: Docker build check | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: [ubuntu-latest] | ||
node-version: [16.x] | ||
fail-fast: true | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Use Node.js ${{matrix.node-version}} | ||
uses: actions/setup-node@v1 | ||
with: | ||
node-version: ${{matrix.node-version}} | ||
- name: Build docker image | ||
run: make build-docker |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
name: Publish Storage-Squid Docker image | ||
|
||
on: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
build_and_publish: | ||
name: Build and Publish | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: '18.x' | ||
|
||
- name: Extract Package Version | ||
id: extract_version | ||
shell: bash | ||
run: | | ||
echo "squid_version=$(cat package.json | jq -r '.version')" >> $GITHUB_OUTPUT | ||
- name: Make some space | ||
shell: bash | ||
run: | | ||
sudo rm -rf /usr/share/dotnet | ||
sudo rm -rf /opt/ghc | ||
sudo rm -rf "/usr/local/share/boost" | ||
sudo rm -rf "$AGENT_TOOLSDIRECTORY" | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
- name: Login to DockerHub | ||
if: github.event_name == 'workflow_dispatch' | ||
uses: docker/login-action@v2 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_PASSWORD }} | ||
|
||
# docker/build-push-action doc: | ||
# Be careful because any file mutation in the steps that precede the | ||
# build step will be ignored, including processing of the .dockerignore file | ||
# since the context is based on the Git reference. However, you can use | ||
# the Path context using the context input alongside the actions/checkout action | ||
# to remove this restriction. | ||
- name: Build storage-squid | ||
uses: docker/build-push-action@v3 | ||
with: | ||
# Do not use local dir context to ensure we can build from a commit directly | ||
# context: . | ||
file: Dockerfile | ||
push: false | ||
load: true | ||
tags: joystream/storage-squid:latest | ||
|
||
- name: Push storage-squid | ||
run: | | ||
docker image tag joystream/storage-squid:latest joystream/storage-squid:${{ steps.extract_version.outputs.squid_version }} | ||
docker push joystream/storage-squid:${{ steps.extract_version.outputs.squid_version }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,5 +10,4 @@ src/model/generated | |
src/types/ | ||
/schema.graphql | ||
/db/persisted | ||
/scripts/orion-v1-migration/data | ||
/db/export |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,5 +7,4 @@ src/types | |
src/model/generated | ||
db/migrations/*.js | ||
schema.graphql | ||
/scripts/orion-v1-migration/data | ||
/db/export |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# 1.0.0 | ||
|
||
- Initial release of `storage-squid` package. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
FROM node:18-alpine AS node | ||
|
||
FROM node AS node-with-gyp | ||
RUN apk add g++ make python3 | ||
|
||
FROM node-with-gyp AS builder | ||
WORKDIR /squid | ||
ADD package.json . | ||
ADD package-lock.json . | ||
ADD assets assets | ||
RUN npm ci | ||
ADD tsconfig.json . | ||
ADD src src | ||
ADD schema schema | ||
ADD scripts scripts | ||
RUN npx squid-typeorm-codegen | ||
RUN npm run build | ||
|
||
FROM node-with-gyp AS deps | ||
WORKDIR /squid | ||
ADD package.json . | ||
ADD package-lock.json . | ||
ADD assets assets | ||
RUN npm ci --omit=dev | ||
|
||
FROM node AS squid | ||
WORKDIR /squid | ||
COPY --from=deps /squid/package.json . | ||
COPY --from=deps /squid/package-lock.json . | ||
COPY --from=deps /squid/node_modules node_modules | ||
COPY --from=builder /squid/lib lib | ||
RUN echo -e "loglevel=silent\nupdate-notifier=false" > /squid/.npmrc | ||
ADD db db | ||
ADD assets assets | ||
ADD schema schema | ||
ADD scripts scripts | ||
ENV PROCESSOR_PROMETHEUS_PORT 3000 | ||
EXPOSE 3000 | ||
EXPOSE 4000 | ||
|
||
|
||
FROM squid AS processor | ||
CMD ["npm", "run", "processor-start"] | ||
|
||
|
||
FROM squid AS query-node | ||
CMD ["npm", "run", "graphql-server-start"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.