Skip to content

Commit

Permalink
integrate with docker
Browse files Browse the repository at this point in the history
  • Loading branch information
s-kaiii committed Nov 27, 2024
1 parent 1ef6ea4 commit 7283c36
Show file tree
Hide file tree
Showing 5 changed files with 140 additions and 20 deletions.
20 changes: 16 additions & 4 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
FROM scratch
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.245.2/containers/codespaces-linux/.devcontainer/base.Dockerfile

WORKDIR .
COPY ./src .
FROM mcr.microsoft.com/vscode/devcontainers/universal:2-focal

EXPOSE 3000
# [Optional] Uncomment this section to install additional OS packages.
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
# && apt-get -y install --no-install-recommends <your-package-list-here>
RUN apt-get update && apt-get -y install --no-install-recommends \
python3.8-venv \
gcc

ARG USER="codespace"
ARG VENV_PATH="/home/${USER}/venv"
COPY requirements.txt /tmp/
COPY Makefile /tmp/
RUN su $USER -c "/usr/bin/python3 -m venv /home/${USER}/venv" \
&& su $USER -c "${VENV_PATH}/bin/pip --disable-pip-version-check --no-cache-dir install -r /tmp/requirements.txt" \
&& rm -rf /tmp/requirements.txt
89 changes: 78 additions & 11 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,79 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
// https://github.com/microsoft/vscode-dev-containers/tree/v0.245.2/containers/codespaces-linux
{
"image": " dot_product",
"customizations": {
"vscode": {
"extensions": [
"streetsidesoftware.code-spell-checker",
"dbaeumer.vscode-eslint"
]
}
},
"forwardPorts": [3000]
}
"name": "GitHub Codespaces (Default)",

"build": {
"dockerfile": "Dockerfile",
"context": ".."
},
"features": {
"ghcr.io/devcontainers/features/nvidia-cuda:1": {
"installCudnn": true
}
},

// Configure tool-specific properties.
"customizations": {
// Configure properties specific to VS Code.
"vscode": {
// Set *default* container specific settings.json values on container create.
"settings": {
"go.toolsManagement.checkForUpdates": "local",
"go.useLanguageServer": true,
"go.gopath": "/go",
"python.defaultInterpreterPath": "/home/codespace/venv/bin/python",
"python.linting.enabled": true,
"python.linting.pylintEnabled": true,
"python.formatting.autopep8Path": "/home/codespace/venv/bin/autopep8",
"python.formatting.blackPath": "/home/codespace/venv/bin/black",
"python.formatting.yapfPath": "/home/codespace/venv/bin/yapf",
"python.linting.banditPath": "/home/codespace/venv/bin/bandit",
"python.linting.flake8Path": "/home/codespace/venv/bin/flake8",
"python.linting.mypyPath": "/home/codespace/venv/bin/mypy",
"python.linting.pycodestylePath": "/home/codespace/venv/bin/pycodestyle",
"python.linting.pydocstylePath": "/home/codespace/venv/bin/pydocstyle",
"python.linting.pylintPath": "/home/codespace/venv/bin/pylint",
"lldb.executable": "/usr/bin/lldb",
"files.watcherExclude": {
"**/target/**": true
}
},

// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"GitHub.vscode-pull-request-github",
"GitHub.copilot-nightly",
"GitHub.copilot-labs",
"ms-azuretools.vscode-docker",
"ms-toolsai.jupyter",
"ms-toolsai.jupyter-keymap",
"ms-toolsai.jupyter-renderers",
"ms-python.vscode-pylance",
"ms-python.python",
"ms-vscode.makefile-tools"
]
}
},

"remoteUser": "codespace",

"overrideCommand": false,

"mounts": ["source=codespaces-linux-var-lib-docker,target=/var/lib/docker,type=volume"],

"runArgs": [
"--cap-add=SYS_PTRACE",
"--security-opt",
"seccomp=unconfined",
"--privileged",
"--init"
],

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

// "oryx build" will automatically install your dependencies and attempt to build your project
//"postCreateCommand": "oryx build -p virtualenv_name=.venv --log-file /tmp/oryx-build.log --manifest-dir /tmp || echo 'Could not auto-build. Skipping.'"
"postCreateCommand": "bash setup.sh"
}
16 changes: 14 additions & 2 deletions .github/workflows/CICD.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12"]
python-version: ["3.9"]

steps:
- uses: actions/checkout@v4
Expand All @@ -27,4 +27,16 @@ jobs:
- name: format
run: make format
- name: lint
run: make lint
run: make lint
- name: Log in to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build image
run: make build
- name: Push image
run: make push
env:
DOCKER_ID_USER: ${{ secrets.DOCKER_USERNAME }}
IMAGE_NAME: skye_mini_project_12
31 changes: 30 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
IMAGE_NAME := skye_mini_project_12
DOCKER_ID_USER := skyea

install:
python3 -m venv venv
venv/bin/pip3 install --upgrade pip &&\
Expand All @@ -12,4 +15,30 @@ test:
lint:
venv/bin/ruff check src/*.py

all: install lint test format
build:
docker build -t $(IMAGE_NAME) .

# Run the Docker container
run:
docker run -p 8000:80 $(IMAGE_NAME)

# Remove the Docker image
clean:
docker rmi $(IMAGE_NAME)

image_show:
docker images

container_show:
docker ps

push:
docker login
docker tag $(IMAGE_NAME) $(DOCKER_ID_USER)/$(IMAGE_NAME)
docker push $(DOCKER_ID_USER)/$(IMAGE_NAME):latest

login:
docker login -u ${DOCKER_ID_USER}

all: install lint test format

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[![CICD](https://github.com/nogibjj/skye-assignment-4/actions/workflows/CICD.yml/badge.svg)](https://github.com/nogibjj/skye-assignment-4/actions/workflows/CICD.yml)

[![CICD](https://github.com/nogibjj/skye-assignment-12/actions/workflows/CICD.yml/badge.svg)](https://github.com/nogibjj/skye-assignment-12/actions/workflows/CICD.yml)
[![Link to docker image](https://www.docker.com/wp-content/uploads/2023/08/logo-guide-logos-1.svg)](https://hub.docker.com/r/skyea/skye_mini_project_12)
# README

## Project Overview
Expand Down

0 comments on commit 7283c36

Please sign in to comment.