Skip to content

Commit

Permalink
build: improve Dockerfile and add push workflow (#141)
Browse files Browse the repository at this point in the history
  • Loading branch information
aht007 authored Oct 20, 2022
1 parent 1a63586 commit f4cd479
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 4 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/push-docker-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Build and Push Docker Images

on:
push:
branches:
- master

jobs:
push:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ secrets.TOOLS_EDX_ECR_USER_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.TOOLS_EDX_ECR_USER_AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1

- name: Log in to ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2

- name: Build, tag, and push image to Amazon ECR
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: openedx-codejail
IMAGE_TAG: latest
run: |
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
13 changes: 9 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ SHELL ["/bin/bash", "-c"]
# Install Codejail Packages
RUN apt-get update && apt-get upgrade -y
RUN apt-get install -y vim python3-virtualenv python3-pip
RUN apt-get install -y sudo
RUN apt-get install -y sudo git

# Define Environment Variables
ENV CODEJAIL_GROUP=sandbox
Expand Down Expand Up @@ -32,18 +32,23 @@ RUN adduser --disabled-login --disabled-password ubuntu --ingroup ubuntu
# Give Ownership of sandbox env to sandbox group and user
RUN chown -R $CODEJAIL_TEST_USER:$CODEJAIL_GROUP $CODEJAIL_TEST_VENV

# Clone Codejail Repo
ADD . ./codejail
WORKDIR /codejail

# Clone Requirement files
COPY ./requirements/sandbox.txt ./codejail/requirements/sandbox.txt
COPY ./requirements/testing.txt ./codejail/requirements/testing.txt

# Install codejail_sandbox sandbox dependencies
RUN source $CODEJAIL_TEST_VENV/bin/activate && pip install -r requirements/sandbox.txt && deactivate

# Install testing requirements in parent venv
RUN pip install -r requirements/sandbox.txt && pip install -r requirements/testing.txt

# Clone Codejail Repo
COPY . ./codejail

# Setup sudoers file
ADD sudoers-file/01-sandbox /etc/sudoers.d/01-sandbox
COPY sudoers-file/01-sandbox /etc/sudoers.d/01-sandbox

# Change Sudoers file permissions
RUN chmod 0440 /etc/sudoers.d/01-sandbox
Expand Down

0 comments on commit f4cd479

Please sign in to comment.