Skip to content

Commit 7319d05

Browse files
Merge pull request #14 from derickson2402/dev
Release v0.4-1 PR
2 parents c961fdd + 1c44acb commit 7319d05

File tree

4 files changed

+132
-23
lines changed

4 files changed

+132
-23
lines changed

.github/workflows/publish.yml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
name: Publish to GHCR
22
on:
3-
push:
4-
tags:
5-
- 'v*'
3+
release:
64

75
jobs:
86
build:
97
runs-on: ubuntu-latest
10-
if: github.ref == 'refs/heads/main'
118
steps:
129
- name: Check out repo
1310
uses: actions/checkout@v2
@@ -19,11 +16,20 @@ jobs:
1916
username: ${{ github.actor }}
2017
password: ${{ secrets.GITHUB_TOKEN }}
2118

22-
- name: Build
19+
- name: Lowercase tag names
20+
id: tag
21+
uses: ASzc/change-string-case-action@v1
22+
with:
23+
string: ${{ github.ref_name }}
24+
25+
- name: Build, tag, and publish
2326
uses: docker/build-push-action@v2
27+
env:
28+
CONTAINER_NAME: ghcr.io/derickson2402/dockerized-caen
2429
with:
2530
context: ./
2631
file: ./Dockerfile
2732
push: true
28-
tags: ghcr.io/${{ github.repository }}:latest,ghcr.io${{ github.repository }}:${{ github.ref.name }}
33+
tags: ${{ env.CONTAINER_NAME }}:latest,${{ env.CONTAINER_NAME }}:${{ steps.tag.outputs.lowercase }}
34+
2935

.github/workflows/testing.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,19 @@ jobs:
1818
username: ${{ github.actor }}
1919
password: ${{ secrets.GITHUB_TOKEN }}
2020

21-
- name: Build and push
21+
- name: Lowercase branch names
22+
id: branch
23+
uses: ASzc/change-string-case-action@v1
24+
with:
25+
string: ${{ github.ref_name }}
26+
27+
- name: Build, tag, and push
2228
uses: docker/build-push-action@v2
29+
env:
30+
CONTAINER_NAME: ghcr.io/derickson2402/dockerized-caen
2331
with:
2432
context: ./
2533
file: ./Dockerfile
2634
push: true
27-
tags: ghcr.io/${{ github.repository }}:${{ github.ref.name }}
35+
tags: ${{ env.CONTAINER_NAME }}:${{ steps.branch.outputs.lowercase }}
2836

Dockerfile

Lines changed: 63 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,86 @@
1-
FROM centos:8
1+
################################################################################
2+
#
3+
# Base container which fixes CentOS EOL
4+
5+
FROM centos:8 AS caen-base
26

37
LABEL maintainer = "Dan Erickson ([email protected])"
48
LABEL version = "v0.3"
5-
LABEL release-date = "2020-04-05"
9+
LABEL release-date = "2022-02-02"
610
LABEL org.opencontainers.image.source = "https://github.com/derickson2402/Dockerized-CAEN"
711

812
ENV USER=1000 \
913
GROUP=1000
10-
1114
VOLUME /code
15+
RUN mkdir -p /usr/um
16+
17+
# CentOS has been deprecated in favor of CentOS stream, so update repo list to search archives
18+
#
19+
# https://forums.centos.org/viewtopic.php?f=54&t=78708
20+
RUN rm -f /etc/yum.repos.d/CentOS-Linux-AppStream.repo \
21+
&& sed -i \
22+
-e 's/mirrorlist.centos.org/vault.centos.org/' \
23+
-e 's/mirror.centos.org/vault.centos.org/' \
24+
-e 's/#baseurl/baseurl/' /etc/yum.repos.d/CentOS-Linux-BaseOS.repo \
25+
&& dnf clean all \
26+
&& dnf swap -y centos-linux-repos centos-stream-repos \
27+
&& dnf install -y --nodocs wget bzip2 tar which
28+
29+
# Set bash as default
30+
SHELL ["/bin/bash", "-c"]
31+
32+
33+
################################################################################
34+
#
35+
# Development environment with basic tools installed, for testing new layers and
36+
# configurations
37+
38+
FROM caen-base AS caen-dev
39+
40+
# Install default packages for developing these containers
41+
RUN dnf update -y \
42+
&& dnf --setopt=group_package_types=mandatory groupinstall --nodocs -y "Development Tools" \
43+
&& dnf install --nodocs -y vim
44+
45+
CMD ["/bin/bash"]
46+
47+
48+
################################################################################
49+
#
50+
# Experimental golang environment
51+
52+
FROM caen-base AS caen-golang
1253

54+
RUN wget https://dl.google.com/go/go1.16.12.linux-amd64.tar.gz -O /tmp/go.tar.gz \
55+
&& tar -C /usr/um -xzf /tmp/go.tar.gz \
56+
&& rm -rf /tmp/go.tar.gz /usr/local/go /usr/go /usr/bin/go \
57+
&& ln -s /usr/um/go/bin/go /usr/bin/go
58+
59+
# Run the container in the user's project folder
60+
WORKDIR /code
61+
CMD ["/bin/bash"]
62+
63+
64+
################################################################################
65+
#
66+
# Default container with all current tools and supported languages
67+
68+
FROM caen-base
69+
70+
# Install dev packages and tools
1371
RUN yum --setopt=group_package_types=mandatory groupinstall --nodocs -y "Development Tools" \
1472
&& yum install --nodocs -y perf valgrind \
1573
&& yum clean all \
1674
&& rm -rf /var/cache/yum \
1775
&& rm -rf /var/lib/rpm/Packages
1876

77+
# Sym link expected location of CAEN compiler just in case
1978
RUN mkdir -p /usr/um/gcc-6.2.0/bin/ \
2079
&& ln -s /usr/bin/gcc /usr/um/gcc-6.2.0/bin/gcc \
2180
&& ln -s /usr/bin/g++ /usr/um/gcc-6.2.0/bin/g++ \
2281
&& echo "export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/code" >> /root/.bashrc
2382

24-
25-
SHELL ["/bin/bash", "-c"]
26-
83+
# Run the container in the user's project folder
2784
WORKDIR /code
28-
2985
CMD ["/bin/bash"]
3086

README.md

Lines changed: 47 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,48 @@
11
# Dockerized-CAEN
22

3-
This is a Docker container running the same debugging software on UofM CAEN servers, which can integrate into your Makefile for automatic testing on your local machine. As of 23 January 2022, the compiler version is 8.50 20210514, so there could be some minor inconsistancies between this container and the actual CAEN servers.
3+
[![Publish Latest](https://github.com/derickson2402/Dockerized-CAEN/actions/workflows/publish.yml/badge.svg)](https://github.com/derickson2402/Dockerized-CAEN/actions/workflows/publish.yml) [![Build test image](https://github.com/derickson2402/Dockerized-CAEN/actions/workflows/testing.yml/badge.svg)](https://github.com/derickson2402/Dockerized-CAEN/actions/workflows/testing.yml)
44

5-
To use this container, you need to have Docker installed on your [macOS](https://docs.docker.com/desktop/mac/install/), [Windows](https://docs.docker.com/desktop/windows/install/), or [Linux](https://docs.docker.com/engine/install/) computer.
6-
7-
With Docker installed and running, simply put the ```caen``` script in your project folder and preface any of your commands with it, like such:
5+
Tired of using ssh and Duo mobile when testing your code with CAEN? With this script, all you have to do is run:
86

97
```bash
108
./caen <program> [args]
119
```
1210

13-
Note that the executables generated with ```./caen make``` will not be executable by your host machine, so run ```make clean``` before switching environments.
11+
This will run your command in an environment identical to CAEN Linux. For example, if you are working on a c++ project for EECS 281, you could use:
12+
13+
```bash
14+
./caen make clean
15+
./caen make my_program.cpp
16+
./caen valgrind my_program.cpp
17+
./caen perf my_program.cpp
18+
```
19+
20+
## Installation
21+
22+
To use this script, you need to have Docker installed on your [macOS](https://docs.docker.com/desktop/mac/install/), [Windows](https://docs.docker.com/desktop/windows/install/), or [Linux](https://docs.docker.com/engine/install/) computer. With Docker installed and running, simply the ```caen``` script in your project folder and preface any of your commands with it. Run the following in your project folder to automatically grab the script:
23+
24+
```bash
25+
wget https://raw.githubusercontent.com/derickson2402/Dockerized-CAEN/main/caen && chmod +x ./caen
26+
```
27+
28+
## How Does This Work?
29+
30+
This script runs your command inside of a Docker Container, which is like a virtual environment running Linux. This environment is set up with CentOS (a fork of the RHEL on CAEN) and all of the tools that you normally use on CAEN. That means that there should be no difference running a program in the container versus on actual CAEN servers, and that the Autograder compiler should work the same as in the container!
31+
32+
## Help! I Need A Program That's Not Installed!
33+
34+
Oops! Sorry about that! Please log an issue [here](https://github.com/derickson2402/Dockerized-CAEN/issues/new) with the name of said program and any special tools that might go along with it. I will add it as soon as I can! For a temporary workaround, see the section below on [hackery](#hackery).
35+
36+
## Useful Tips
1437

1538
This container is currently under development, but the script does not check for updates automatically. To get the newest container version, run the following in a terminal with Docker running:
1639

1740
```bash
1841
docker pull ghcr.io/derickson2402/dockerized-caen:latest
1942
```
2043

44+
Executables generated with this container are compiled for CAEN servers and won't work on your host system. You should run your ```make clean``` script before switching back and forth, and then run ```make``` from the environment you want to use.
45+
2146
You can also integrate CAEN with your ```Makefile``` so that when you call ```make [job]``` it automatically runs in the container. Do this by replacing the ```CXX``` variable with the following:
2247

2348
```Makefile
@@ -27,12 +52,26 @@ CXX = ./caen g++
2752
If you do not want to download the ```caen``` script, you can also just preface your commands with the following, but this is not recommended:
2853

2954
```bash
30-
docker run --rm -it --pull -v "$(pwd):/code" ghcr.io/derickson2402/dockerized-caen:latest <valgrind|perf> <program> [args]
55+
docker run --rm -it -v "$(pwd):/code" ghcr.io/derickson2402/dockerized-caen:latest <valgrind|perf> <program> [args]
56+
```
57+
58+
## Hackery
59+
60+
If the container environment is not suiting your needs, you can always run the container manually and hack it into working. The problem is that the update won't survive a container restart, so change the normal script like so:
61+
62+
```bash
63+
docker run -it --name caen-tainer -v "$(pwd):/code" ghcr.io/derickson2402/dockerized-caen:latest bash
64+
```
65+
66+
The important part is to get rid of the ```--rm``` tag so the container isn't destroyed when it exits, and to give it a name to easily reference it with (you don't have to use ```caen-tainer```, but I thought it was funny :smile:). You should be able to jump back into the container with either of:
67+
68+
```bash
69+
docker start -ai caen-tainer
70+
docker exec -it caen-tainer <command>
3171
```
3272

33-
# Contributing
73+
## Contributing
3474

3575
I started working on this project while taking EECS-281, in order to make debugging my programs easier. I am sharing this project online in hopes that others will find it useful, but note that I don't have much free time to develop this project.
3676

3777
With that said, if you have an idea that would make this project even better, feel free to log an issue or submit a Pull Request. I greatly appreciate any help on developing this project!
38-

0 commit comments

Comments
 (0)