Comments (18)
Ahhh, the OverloadedLists
was the crucial part. Must have missed it in your examplesβ¦
Thanks a lot!
from language-docker.
Yes, multistage images are the reason this project exists at all.
That said, it works much better when using multistage builds with ONBUILD instructions. That means, having each stage in a different file.
Do you need guidance in using this tool?
from language-docker.
If I recall correctly, this is not the same!
With builder images you can copy just a few things from one image to the next:
COPY --from=builder /var/app/node_modules node_modules
This is not possible with onbuild images.
from language-docker.
This is the documentation for it:
https://docs.docker.com/develop/develop-images/multistage-build/
from language-docker.
I guess I should have read it until the end π :
When using multi-stage builds, you are not limited to copying from stages you created earlier in your Dockerfile.
I'll try out if I can make it work this wayβ¦
from language-docker.
@ad-si Let me know if you need help!
from language-docker.
Thanks! Actually, I already have a question. How can I build this:
COPY --from=builder /var/app/node_modules node_modules
from language-docker.
@ad-si are you suing the DSL or using the quasi quoter?
Using the quasi quoter:
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE QuasiQuotes #-}
import Language.Docker
main = putStr $ toDockerfileStr $ do
[edockerfile|
FROM node as builder
FROM node
COPY --from=builder /var/app/node_modules node_modules
CMD node something.js
|]
Using the DSL:
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE QuasiQuotes #-}
import Language.Docker
import Language.Docker.Syntax as Syntax
main = putStr $ toDockerfileStr $ do
from $ "node" `aliased` "builder"
from "node"
copyFrom "builder" ["/var/app/node_modules"] "node_modules"
where
copyFrom img sources dest = copyArgs sources dest Syntax.NoChown (Syntax.CopySource img)
I realise now that there should be a helper function in the DSL for this common case. I'll work on that soon. Let me know if this worked for you
from language-docker.
Thanks for the examples!
I don't use QuasiQuotes (when possible). Neither a fan of the Docker syntax, nor of Template Haskell.
Would be really could if you'd add first class support to the EDSL. π
We use this features basically in every Dockerfile nowadays.
from language-docker.
I'll give a stabat it this weekend... or maybe you want to help me with that? I can guide you if you are interested
from language-docker.
Uhm, my real GitHub account (@adius) is currently blocked (don't ask π€¦ββοΈ). I don't want to use my current temporary account for contributions. When (if) it gets unlocked I could help out ...
from language-docker.
Stupid question: There must be an easier way, right? π
copy (NonEmpty.fromList [SourcePath "test.json"]) (TargetPath "test.json")
from language-docker.
@ad-si both SourcePath
and TargetPath
have as IsString
instance. So if you add these two extensions:
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE OverloadedLists #-}
You should be able to write:
copy ["test.json"] "test.json"
from language-docker.
@ad-si I'm thinking of changing the DSL for copy
. what do you think of this?
copy $ fromStage "builder" $ ["test.json"] `to` "/app/"
from language-docker.
Mh, looks a little to involved for me. Sometime simpler is better. What's wrong with:
copyFromStage "builder" ["test.json"] "/app/"
There isn't even additional type safety, is there?
from language-docker.
I can for sure offer a simpler version once I get the completed cases sorted out. The complex case is having both from and chows as flags for copy.
The api I suggested a iced would support having both, either or none of the flags (and future flags) in the same syntax.
from language-docker.
Ah I see, sounds good.
But the to
wouldn't be necessary, right?
from language-docker.
Yeah, it is somewhat necessary. I'll explore alternative designs that may also work
from language-docker.
Related Issues (20)
- Build failure with ghc 8.4 HOT 1
- src/Language/Docker/PrettyPrint.hs:91:25: error: Not in scope: 'fail' HOT 2
- [Feature Request] EXPOSE UDP port *range* HOT 4
- Parse RUN agruments do not respect control operators HOT 1
- Fail to compile language-docker-5.0.1 HOT 2
- Cannot parse if line ends with linebreak and space HOT 2
- Unexpected parser error in language-docker-6.0.1 HOT 5
- 'from "opensuse/tumbleweed"' gives unexpected result HOT 1
- 'label' has to quote arguments HOT 1
- Inaccurate version bounds HOT 2
- #escape=` is not supported HOT 1
- compilation with ghc 8.8.2 stack 15.1 HOT 4
- GHC 8.10.1 build issues
- Pretty printing of `RUN` in shell form replaces multiple spaces in quoted string HOT 1
- sdist doesn't include all necessary files for tests
- Test files missing from release tarball HOT 2
- Add --link flag to COPY/ADD instrructions HOT 1
- Support for heredocs HOT 6
- Wrong escaping of `\` when parsing ENV instructions HOT 1
- prettyPrint does not preseve the content of quoted string
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from language-docker.