Created
September 21, 2022 09:39
-
-
Save adamazad/f88e80aebefc6f74e5967477ce3daac5 to your computer and use it in GitHub Desktop.
Swapr 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
node_modules | |
.netlify | |
.github | |
.vscode | |
build | |
cypress | |
tests | |
yarn-error.log | |
npm-debug.log | |
.storybook |
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
#!/bin/bash | |
# Extract build information from git | |
GIT_COMMIT=$(git rev-parse HEAD) | |
GIT_TAG=$(git tag --points-at HEAD) | |
GIT_BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD | sed 's/[^a-zA-Z0-9]/-/g') | |
# Use tag if exists, resort to branch name | |
GIT_REVISION=$GIT_TAG | |
if [ !$GIT_TAG ] | |
then | |
GIT_REVISION=$GIT_BRANCH_NAME | |
elif [ !$GIT_BRANCH_NAME ] | |
then | |
GIT_REVISION=$GIT_COMMIT | |
fi | |
# Construct Docker image | |
# DOCKER_TAG=$GIT_REVISION | |
DOCKER_IMAGE_NAME="swapr-dapp" | |
DOCKER_IMAGE_TAG="${DOCKER_IMAGE_NAME}:${GIT_REVISION}" | |
echo "Building ${DOCKER_IMAGE_TAG} @ ${GIT_COMMIT} from ${GIT_REVISION}" | |
docker build --file ./docker/Dockerfile --tag ${DOCKER_IMAGE_TAG} --build-arg "GIT_COMMIT=${GIT_COMMIT}" --build-arg "GIT_REVISION=${GIT_REVISION}" . |
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
# pull official base image | |
FROM node:16.14.2 | |
# Arguments | |
ARG IPFS_DEPLOY_PINATA__API_KEY | |
ARG IPFS_DEPLOY_PINATA__SECRET_API_KEY | |
# Install Java | |
RUN apt-get update && \ | |
apt-get install -y openjdk-11-jdk ca-certificates-java && \ | |
apt-get clean && \ | |
update-ca-certificates -f | |
ENV JAVA_HOME /usr/lib/jvm/java-11-openjdk-amd64/ | |
RUN export JAVA_HOME | |
# Install IPFS | |
RUN wget https://dist.ipfs.tech/kubo/v0.15.0/kubo_v0.15.0_linux-amd64.tar.gz && \ | |
tar -xvzf kubo_v0.15.0_linux-amd64.tar.gz && \ | |
cd go-ipfs && \ | |
./install.sh && \ | |
cd .. && \ | |
rm -rf go-ipfs && \ | |
rm kubo_v0.15.0_linux-amd64.tar.gz | |
# Run IPFS daemon | |
# RUN ipfs init | |
# set working directory | |
WORKDIR / | |
# ensure that devDependencies are installed | |
ENV NODE_ENV development | |
COPY package.json ./ | |
COPY yarn.lock ./ | |
COPY . ./ | |
# install app dependencies | |
RUN yarn install --frozen-lockfile | |
# Prepare the app for production | |
RUN yarn codegen:socket | |
# build app for production | |
ENV NODE_ENV production | |
# Build the app | |
RUN yarn ipfs-build | |
# Install global dependencies | |
RUN npm install -g ipfs-deploy serve | |
ENV IPFS_DEPLOY_PINATA__API_KEY=$IPFS_DEPLOY_PINATA__API_KEY IPFS_DEPLOY_PINATA__SECRET_API_KEY=$IPFS_DEPLOY_PINATA__SECRET_API_KEY | |
RUN ipfs add -rn build | |
# start app via serve | |
CMD ["npx", "serve", "build"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment