Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: port Containerfile to use Vib's recipe #8

Merged
merged 1 commit into from
Apr 29, 2024

Conversation

kbdharun
Copy link
Member

@kbdharun kbdharun commented Apr 22, 2024

Changes

This PR ports the Containerfile to be generated via a Vib recipe file. (cc @matbme) [I have tested the generated image at https://github.com/kbdharun/Differ/pkgs/container/differ.]

Details

Current Containerfile:

FROM docker.io/golang:1.21-alpine
LABEL maintainer="Mateus Melchiades"

WORKDIR /home/user

# Install dependencies
RUN apk add --update gcc musl-dev sqlite make

# Copy project files and build
COPY main.go go.mod go.sum go.work Makefile /home/user/
COPY core /home/user/core/
COPY diff /home/user/diff/
COPY types /home/user/types/
COPY vendor /home/user/vendor/
RUN make

# Cleanup
RUN rm -rf main.go go.mod go.sum go.work Makefile core/ types/ vendor/

EXPOSE 8080

CMD ["/home/user/differ"]

New Vib generated Containerfile:

# Stage: build
FROM docker.io/golang:1.21-alpine AS build
LABEL maintainer='Mateus Melchiades'
EXPOSE 8080/
ADD includes.container /
ADD sources /sources
RUN mkdir /home/user && cp /sources/init/main.go /home/user/ && cp /sources/init/go.mod /home/user/ && cp /sources/init/go.sum /home/user/ && cp /sources/init/go.work /home/user/ && cp /sources/init/Makefile /home/user/ && mv /sources/init/core /home/user/core/ && mv /sources/init/diff /home/user/diff/ && mv /sources/init/types /home/user/types/ && mv /sources/init/vendor /home/user/vendor/ && rm -rf /sources/init
RUN apk add gcc musl-dev sqlite make
RUN cd /home/user && make
RUN rm -rf main.go go.mod go.sum go.work Makefile core/ types/ vendor/
CMD ["/home/user/differ"]

Note

WORKDIR instruction is currently not supported in Vib; I haven't tested COPY instruction in Vib outside of moving files between stages (if that works, I am open to optimizing the RUN command moving all the assets. Also, I tried using the make built-in module but it didn't work while testing so switched to shell type.

@matbme matbme merged commit 3e4451e into Vanilla-OS:main Apr 29, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants