Skip to content

Commit

Permalink
update user licensed image build
Browse files Browse the repository at this point in the history
  • Loading branch information
mfshao committed Nov 19, 2024
1 parent 71699ba commit 5187569
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 54 deletions.
54 changes: 13 additions & 41 deletions .github/workflows/build_push_stata_user_licensed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,44 +8,16 @@ on:
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Maximize build space
uses: easimon/maximize-build-space@master
with:
root-reserve-mb: 30000
swap-size-mb: 1024
remove-dotnet: 'true'
remove-android: 'true'
remove-haskell: 'true'
- uses: actions/checkout@v2
- uses: prewk/[email protected]
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
SOURCE: 's3://ctds-stata/Stata17Linux64.tar.gz'
DEST: './jupyter-pystata-user-licensed/resources/'

- name: Extract branch name
shell: bash
run: echo "::set-output name=branch::$(echo $(echo ${GITHUB_REF#refs/*/} | tr / _))"
id: extract_branch

- name: Build Image
id: build-image
uses: redhat-actions/buildah-build@v2
with:
image: jupyter-pystata-user-licensed
tags: ${{ steps.extract_branch.outputs.branch }}
dockerfiles: ./jupyter-pystata-user-licensed/Dockerfile

- name: Push To quay.io
id: push-to-quay
uses: redhat-actions/push-to-registry@v2
with:
image: ${{ steps.build-image.outputs.image }}
tags: ${{ steps.build-image.outputs.tags }}
registry: quay.io/cdis
username: ${{ secrets.QUAY_SERVICE_ACCOUNT_USER }}
password: ${{ secrets.QUAY_SERVICE_ACCOUNT_PASSWORD }}
stata_user-licensed:
name: Build and Push user licensed Stata workspace image
uses: uc-cdis/.github/.github/workflows/image_build_push.yaml@master
with:
DOCKERFILE_LOCATION: "./jupyter-pystata-user-licensed/Dockerfile"
DOCKERFILE_BUILD_CONTEXT: "./jupyter-pystata-user-licensed"
OVERRIDE_REPO_NAME: "jupyter-pystata-user-licensed"
OVERRIDE_TAG_NAME: "jupyter-pystata-user-licensed-$(echo ${GITHUB_REF#refs/*/} | tr / _)"
secrets:
ECR_AWS_ACCESS_KEY_ID: ${{ secrets.ECR_AWS_ACCESS_KEY_ID }}
ECR_AWS_SECRET_ACCESS_KEY: ${{ secrets.ECR_AWS_SECRET_ACCESS_KEY }}
QUAY_USERNAME: ${{ secrets.QUAY_USERNAME }}
QUAY_ROBOT_TOKEN: ${{ secrets.QUAY_ROBOT_TOKEN }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.vscode/*
.DS_store
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
repos:
- repo: [email protected]:Yelp/detect-secrets
rev: v1.4.0
rev: v1.5.0
hooks:
- id: detect-secrets
args: ['--baseline', '.secrets.baseline']
exclude: .lock
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.5.0
rev: v4.6.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
Expand Down
2 changes: 1 addition & 1 deletion .secrets.baseline
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "1.4.0",
"version": "1.5.0",
"plugins_used": [
{
"name": "ArtifactoryDetector"
Expand Down
15 changes: 7 additions & 8 deletions jupyter-pystata-user-licensed/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM quay.io/cdis/jupyter-superslim:1.0.5
FROM quay.io/cdis/jupyter-superslim:2.0.0

USER root
RUN apt-get update
Expand All @@ -7,24 +7,23 @@ RUN apt-get update
RUN apt-get install -y libncurses5

RUN mkdir /usr/local/stata17
COPY jupyter-pystata-user-licensed/resources/Stata17Linux64.tar.gz /tmp/Stata17Linux64.tar.gz
COPY ./resources/Stata17Linux64.tar.gz /tmp/Stata17Linux64.tar.gz
RUN cd /usr/local/stata17 && tar -xvf /tmp/Stata17Linux64.tar.gz

RUN chown $NB_USER /usr/local/stata17/
ENV PATH $PATH:/usr/local/stata17
ENV PATH=$PATH:/usr/local/stata17
RUN cd /usr/local/stata17 && \
{ echo y; echo y; echo y; } | ./install

COPY jupyter-pystata-user-licensed/resources/Stata.ipynb .
COPY jupyter-pystata-user-licensed/resources/welcome.html .
COPY ./resources/Stata.ipynb .
COPY ./resources/welcome.html .

USER $NB_USER
RUN pip install --user stata_setup==0.1.2

COPY jupyter-pystata-user-licensed/dockerstart.sh /usr/local/bin/
COPY ./dockerstart.sh /usr/local/bin/

RUN mkdir /tmp/custom_api
COPY jupyter-pystata-user-licensed/resources/custom_api/* /tmp/custom_api/
ENV PYTHONPATH="${PYTHONPATH}:/tmp/"
COPY ./resources/custom_api/* /tmp/custom_api/

CMD /usr/local/bin/dockerstart.sh
2 changes: 1 addition & 1 deletion jupyter-pystata-user-licensed/dockerstart.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ if [[ -z "${STATA_LICENSE}" ]]; then
else
echo $STATA_LICENSE > /usr/local/stata17/stata.lic
unset STATA_LICENSE
start-notebook.sh --NotebookApp.nbserver_extensions="{'custom_api.ready_handler':True}" $NOTEBOOK_ARGS $@ &
start-notebook.sh --JupyterNotebookApp.nbserver_extensions="{'custom_api.ready_handler':True}" $NOTEBOOK_ARGS $@ &
JUPYTER_PID=$!
sleep 10

Expand Down
2 changes: 1 addition & 1 deletion jupyter-pystata-user-licensed/resources/welcome.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ <h5>User license workspace</h5>

<P>
As a one-time step, workspace users should add their license files
in their persistant workspace storage as
in their persistent workspace storage as
<pre>~/pd/stata.lic</pre>
The notebook has a few lines of python code to check for the
license file and copy it to the appropriate location so that Stata can recognize it.
Expand Down

0 comments on commit 5187569

Please sign in to comment.